|
Hello All,
How to compare two enum types?
Thanks
|
|
|
|
|
If you need to, then you should probably use the one enum in both cases.
you have two options:
1 - cast both to int, if you can make the int values correlate ( but then just use the one enum )
2 - write a method that applies whatever comparison rules you need, by hand.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
use the typeof(ur enum) with compare() method
|
|
|
|
|
How would that work, exactly ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Good question
i have put small exmaple here
public enum Named : int
{
A,
B,
C,
D
}
public enum Names : byte
{
A,
B,
C,
D
}
check
if (Enum.Equals(typeof(Named),typeof(Names)))
{
//type is equal
}
thanks you
|
|
|
|
|
OK - so does that compare based on enum name, or their intrinsic int value ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I seen your profile,your are MVP in code project, Are you checking me?
Basically Compare based on the type of the enum
You can understand from my example.
Thank you
|
|
|
|
|
No, I've never seen this before, I would think that comparing two different enums is a bad design, I'm curious how it would work.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
So
is it wrong? or is it can't be exist like that?
|
|
|
|
|
I am saying I've never used it, I was curious how it works, although I'd never use it, personally.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
You're trying to compare the types to each other. The enum Equals takes two enum values.
www.wickedorange.com
www.andrewvos.com
|
|
|
|
|
*The enum Equals can take two enum values
www.wickedorange.com
www.andrewvos.com
|
|
|
|
|
Since I haven't tried this before, are there any major problems with launching an external process from a BackgroundWorker thread?
Just thought I'd ask before I try and start pulling what little hair I have left.
Thanks in advance,
Steve.
|
|
|
|
|
that is the wrong order if you ask me.
first read the documentation and/or try; if you still have a problem, then ask and
the CodeProject will try and help you.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
HI thompsons
what you means by the external process?
In my undestand, You are try start a notepad exe in same PC, is it?
is it correct ,can up external process.
|
|
|
|
|
Rule #1, try it!
No, there's no problem with doing that at all. A new process starts on it's own thread anyway, so it really doesn't matter which thread you start a new proc on.
|
|
|
|
|
To all:
Thanks for the reply.
My apologies for breaking rule #1; wasn't aware of it...
Regards,
Steve.
|
|
|
|
|
Hi, I've only taken 2 programming classes thus far so I am fairley new to it all (but I love it so far!). I made an application to take and store all my notes for all my different classes (college). The problem I am having is, I want to display a powerpoint and be able to navigate through it in either a webrowser or picturebox beside my richtextbox for my notes. Is there a simple way to do this? I've searched the web a lot and can't seam to find anything? Any help would be great! thanks
Rusty
|
|
|
|
|
You can control office through the microsoft tools for office ( or something like that ). You can't display a ppt on a machine that doesn't have powerpoint installed, but I'd expect you could perhaps do it through the libraries MS provides, on a machine that has it.
You definately cannot do it in a picturebox, if you can do it through a browser control, it's only because the browser itself knows how to open a powerpoint ( I'm not sure if it opens them embedded, like PDFs will open )
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
This is the header of my only function in my dll file and it compiles just fine
public static string SaveName(string strName)
and on the other hand in my class that implements the dll I have this:
[DllImport("MyBloodyDLL.dll", EntryPoint = "SaveName")]
public static extern string SaveName(string strName);
and when calling the SaveName("string") function later, I get this beautiful exception:
Unable to find an entry point named 'SaveName' in DLL 'MyBloodyDLL.dll
Please help
ps. I HATE DLLs!!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
modified on Wednesday, April 16, 2008 4:49 PM
|
|
|
|
|
strName!=SaveName
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Luc Pattyn wrote: strName!=SaveName
Sorry Luc, I just made a mistake while pasting it, any idea what the problem is??
Thanks for helping mate!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
modified on Wednesday, April 16, 2008 4:54 PM
|
|
|
|
|
Hi Muammar,
if your target file is unmanaged C++ (as opposed to C) then the function names
would be mangled somehow. You could either try and find out what the rules are,
or use good old DUMPBIN to look at the exports of the DLL.
BTW: maybe just omitting the EntryPoint stuff solves it (just a guess).
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hey Luc,
Well, both files are written in C# "guess that's why i'm posting this in the C# forum "
Luc Pattyn wrote: maybe just omitting the EntryPoint stuff solves it
While I though adding it would solve the problem .. I just added it after the problem has occurred!
Anyways, thanks for helping Luc!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|