473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

how to know an int is the member of an enum type?(C++/CLI)

Tau
for example:
enum class SomeEnumType
{
A1 = 1;
A2 = 2;
A3 = 3;
};
how to write a function like:
bool isOneOfSomeEnumType(int i)? (in C++/CLI)

isOneOfSomeEnumType(1) will return true
isOneOfSomeEnumType(2) will return true
isOneOfSomeEnumType(4) will return false

somebody helps me! Thanks!

Jan 19 '06 #1
9 1924
Hi Tau!
for example:
enum class SomeEnumType
{
A1 = 1;
A2 = 2;
A3 = 3;
};
how to write a function like:
bool isOneOfSomeEnumType(int i)? (in C++/CLI)


return System::Enum::IsDefined(SomeEnumType::typeid, i);
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Jan 19 '06 #2
Tau
Great!
Thanks

Jan 19 '06 #3
> return System::Enum::IsDefined(SomeEnumType::typeid, i);

What exactly is 'typeid' here? Only thing I could find suggests I would need
an existing variable of SomeEnumType type to do a GetType() and get this
'typeid'. Put another way, does it takes one to know one? ; )

[==P==]

"Jochen Kalmbach [MVP]" <no********************@holzma.de> wrote in message
news:ux**************@TK2MSFTNGP10.phx.gbl...
Hi Tau!
for example:
enum class SomeEnumType
{
A1 = 1;
A2 = 2;
A3 = 3;
};
how to write a function like:
bool isOneOfSomeEnumType(int i)? (in C++/CLI)


return System::Enum::IsDefined(SomeEnumType::typeid, i);
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/

Jan 19 '06 #4
Hi Peter!
return System::Enum::IsDefined(SomeEnumType::typeid, i);

What exactly is 'typeid' here? Only thing I could find suggests I would need
an existing variable of SomeEnumType type to do a GetType() and get this
'typeid'.


I C# the equivalent is "typeof(SomeEnumType)"...

See also:
http://msdn2.microsoft.com/en-us/library/ms235260.aspx
http://msdn2.microsoft.com/en-us/library/kwd9abya.aspx

For "typeid" you do not need to have a instance of the object....

Put another way, does it takes one to know one? ; )


I donÂīt understand...
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Jan 19 '06 #5
> Put another way, does it takes one to know one? ; )
I donīt understand...
Sorry, a bad attempt at humor. There is a saying "it takes one to know one".
In this context, if it was required to create an instance of an object type
in order to identify if another object is of the same type, I felt the
saying was somewhat appropriate and therefore kinda humerous. As you've
explained, however, this is not necessary, so the statement is not so funny
anymore....hehe

[==P==]

"Jochen Kalmbach [MVP]" <no********************@holzma.de> wrote in message
news:Oi*************@TK2MSFTNGP09.phx.gbl...
Hi Peter!return System::Enum::IsDefined(SomeEnumType::typeid, i);

What exactly is 'typeid' here? Only thing I could find suggests I would
need an existing variable of SomeEnumType type to do a GetType() and get
this 'typeid'.


I C# the equivalent is "typeof(SomeEnumType)"...

See also:
http://msdn2.microsoft.com/en-us/library/ms235260.aspx
http://msdn2.microsoft.com/en-us/library/kwd9abya.aspx

For "typeid" you do not need to have a instance of the object....

Put another way, does it takes one to know one? ; )


I donīt understand...
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/

Jan 19 '06 #6
Hi Peter!
Put another way, does it takes one to know one? ; )
I donÅ―t understand...


Sorry, a bad attempt at humor. There is a saying "it takes one to know one".


English is not my native language... so I didnÂīt know this term... but
now I learned thanks!
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Jan 19 '06 #7
For someone who's 'english is not their native language' you communicate in
English a lot better than some people I know for whom 'english IS their
native language'... ; )

[==P==]

"Jochen Kalmbach [MVP]" <no********************@holzma.de> wrote in message
news:ux**************@TK2MSFTNGP09.phx.gbl...
Hi Peter!
Put another way, does it takes one to know one? ; )

I donZt understand...


Sorry, a bad attempt at humor. There is a saying "it takes one to know
one".


English is not my native language... so I didnīt know this term... but now
I learned thanks!
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/

Jan 19 '06 #8

"Peter Oliphant" wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Put another way, does it takes one to know one? ; )
I donīt understand...

Sorry, a bad attempt at humor. There is a saying "it takes one to know
one".


The most common usage is in response to being called an idiot, newbie, or
other derogatory term. See also: "It takes a thief to catch a thief"
In this context, if it was required to create an instance of an object
type in order to identify if another object is of the same type, I felt
the saying was somewhat appropriate and therefore kinda humerous. As
you've explained, however, this is not necessary, so the statement is not
so funny anymore....hehe

[==P==]

"Jochen Kalmbach [MVP]" <no********************@holzma.de> wrote in
message news:Oi*************@TK2MSFTNGP09.phx.gbl...
Hi Peter!
return System::Enum::IsDefined(SomeEnumType::typeid, i);
What exactly is 'typeid' here? Only thing I could find suggests I would
need an existing variable of SomeEnumType type to do a GetType() and get
this 'typeid'.


I C# the equivalent is "typeof(SomeEnumType)"...

See also:
http://msdn2.microsoft.com/en-us/library/ms235260.aspx
http://msdn2.microsoft.com/en-us/library/kwd9abya.aspx

For "typeid" you do not need to have a instance of the object....

Put another way, does it takes one to know one? ; )


I donīt understand...
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/


Jan 19 '06 #9
Tau
Does this become a language learning thread?
I mean not the program language but the English language... :-)

Jan 20 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: cartoper | last post by:
I am writing C# code that interacts with a external device's firmware which is writen in C. There is a common enum file the firmware code is using that I would like to consume in the C# world. I...
2
by: Phil Davidson | last post by:
/* (Posted to microsoft.public.dotnet.languages.vc) In C++/CLI under Visual Studio 2005, creating an "enum class" member called "Equals" can cause compiler error C1060 (out of memory) and C1063...
12
by: Cmtk Software | last post by:
I'm trying to define an enum which will be used from unmanaged c++, C++/CLI managed c++ and from C#. I defined the following enum in a VS dll project set to be compiled with the /clr switch: ...
1
by: =?Utf-8?B?d3BjbWFtZQ==?= | last post by:
I got the following code public ref class A { value struct PrivateType sealed { Int32 id; }; public: ref struct B abstract sealed { static const PrivateType x = {1}; static const PrivateType...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.