Click here to Skip to main content
15,940,271 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I have a problem creating an enumerator for some special characters...

So how can I achive the following(if its possible of course):

C#
public enum MyEnumerator
{
    InboundDocument = ->,
    OutbountDocument = <-,
    MyOwnDocument = v 
}


Thank you for your answer...
Posted
Updated 10-Jul-12 22:40pm
v2
Comments
Rahul Rajat Singh 11-Jul-12 4:36am    
Your question is not clear. and what is this code you provided. This is now how an enum is defined.
pykos 11-Jul-12 4:41am    
Sorry I mixed the order, the question is how to use "->" this kind of character in enumerator?

That is not how enum works. Enum can map an integral value to named constants, that are identifiers, thus have to conform to following syntax rules: http://msdn.microsoft.com/en-us/library/aa664670(v=vs.71).aspx[^]. On the other hand, values has to be integral type, see: http://msdn.microsoft.com/en-us/library/sbbt4032(v=vs.80).aspx[^]
You can however add attributes, and read them with reflection. Look here: http://stackoverflow.com/questions/3916914/c-sharp-using-numbers-in-an-enum[^]
 
Share this answer
 
 
Share this answer
 
I think this might work

C#
public enum MyEnumerator
{
    [Description("->")]
    InboundDocument = 0,
    [Description("<-")]
    OutbountDocument = 1,
    [Description("V")]
    MyOwnDocument = 2
}


Thanks...
 
Share this answer
 
After you clarification you probably need something like this:

C#
public sealed class DocumentFlowDirections
	{
	    public const string InboundDocument = "->";
	    public const string OutbountDocument = "<-";
	    public const string MyOwnDocument = "v"; 
	}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900