Alternatives to Enum.Parse and Enum.Format

  • Thread starter Thread starter ME
  • Start date Start date
M

ME

What are the .NET Compact Framework Alternatives to Enum.Parse and
Enum.Format as they are not supported by the Compact Framework?

Thanks,

Matt
 
Thanks,

What about the Enum.Format method? Is there an alternative way to perform
this task:
[Flags]
public enum TypesToCompare
{
none = 0
option1 = 1
option2 = 2
option3 = 4
option4 = 8
}
-----snip------
string enums;
enumTypeToCompare = TypesToCompare.option4 + TypesToCompare.option2

enums = Enum.Format(enumTypeToCompare, TypesToCompare, "f");

the resulting string would yeild:

"4, 2"

Thanks,



Matt
 
Sorry, my bad the resulting string would yeild "8, 2"

Thanks,

Matt
ME said:
Thanks,

What about the Enum.Format method? Is there an alternative way to perform
this task:
[Flags]
public enum TypesToCompare
{
none = 0
option1 = 1
option2 = 2
option3 = 4
option4 = 8
}
-----snip------
string enums;
enumTypeToCompare = TypesToCompare.option4 + TypesToCompare.option2

enums = Enum.Format(enumTypeToCompare, TypesToCompare, "f");

the resulting string would yeild:

"4, 2"

Thanks,



Matt

Use OpenNETCF's SDF. It has the EnumEx class.

www.opennetcf.org/sdf

-Chris
 
I'll make a note of a feature request for Format(). One slightly messy way
to do this right now would be to do a tostring which should give you
"option4, option2" then split this and do a Parse on each member, get the
integer value, the reassemble back into a string.

Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://www.peterfoot.net |
http://www.opennetcf.org

ME said:
Sorry, my bad the resulting string would yeild "8, 2"

Thanks,

Matt
ME said:
Thanks,

What about the Enum.Format method? Is there an alternative way to
perform this task:
[Flags]
public enum TypesToCompare
{
none = 0
option1 = 1
option2 = 2
option3 = 4
option4 = 8
}
-----snip------
string enums;
enumTypeToCompare = TypesToCompare.option4 + TypesToCompare.option2

enums = Enum.Format(enumTypeToCompare, TypesToCompare, "f");

the resulting string would yeild:

"4, 2"

Thanks,



Matt

Use OpenNETCF's SDF. It has the EnumEx class.

www.opennetcf.org/sdf

-Chris



What are the .NET Compact Framework Alternatives to Enum.Parse and
Enum.Format as they are not supported by the Compact Framework?

Thanks,

Matt
 
Back
Top