[Mono-devel-list] mcs not recognizing FlagsAttribute?
jpease at twcny.rr.com
jpease at twcny.rr.com
Wed Jul 7 13:10:08 EDT 2004
I compiled the following sample MSDN library code for the FlagsAttribute class and ran with mono to find that the output was not as expected. It is the same with/without the FlagsAttribute specified. A monodis of the compiled code doesn't show any reference to the attribute.
I'm using the most recent Fedora Core 1 rpms. Has anyone else had similar problems, or is there something I'm missing? The example appears to be OK...
// Example of the FlagsAttribute attribute.
using System;
class FlagsAttributeDemo
{
// Define an Enum without FlagsAttribute.
enum SingleHue : short
{
Black = 0,
Red = 1,
Green = 2,
Blue = 4
};
// Define an Enum with FlagsAttribute.
[FlagsAttribute]
enum MultiHue : short
{
Black = 0,
Red = 1,
Green = 2,
Blue = 4
};
static void Main( )
{
Console.WriteLine(
"This example of the FlagsAttribute attribute \n" +
"generates the following output." );
Console.WriteLine(
"\nAll possible combinations of values of an \n" +
"Enum without FlagsAttribute:\n" );
// Display all possible combinations of values.
for( int val = 0; val <= 8; val++ )
Console.WriteLine( "{0,3} - {1}",
val, ( (SingleHue)val ).ToString( ) );
Console.WriteLine(
"\nAll possible combinations of values of an \n" +
"Enum with FlagsAttribute:\n" );
// Display all possible combinations of values.
// Also display an invalid value.
for( int val = 0; val <= 8; val++ )
Console.WriteLine( "{0,3} - {1}",
val, ( (MultiHue)val ).ToString( ) );
}
}
/*
This example of the FlagsAttribute attribute
generates the following output.
All possible combinations of values of an
Enum without FlagsAttribute:
0 - Black
1 - Red
2 - Green
3 - 3
4 - Blue
5 - 5
6 - 6
7 - 7
8 - 8
All possible combinations of values of an
Enum with FlagsAttribute:
0 - Black
1 - Red
2 - Green
3 - Red, Green
4 - Blue
5 - Red, Blue
6 - Green, Blue
7 - Red, Green, Blue
8 - 8
*/
More information about the Mono-devel-list
mailing list