problem with enum type ?!
-
big noob problem :) i've got that public enum W32_DriveTypes : int { Unknown = 0, NoRootDirectory = 1, Removable = 2, LocalDisk = 3, NetworkDrive = 4, CompactDisc = 5, RAMDisk = 6 } and for my switch to wroks i need to put (int) in front ... ?! switch( int.Parse(mo["DriveType"].ToString()) ) { case (int)W32_DriveTypes.Removable : idxicon = 8; break; case (int)W32_DriveTypes.LocalDisk : idxicon = 4; break; case (int)W32_DriveTypes.NetworkDrive : idxicon = 6; break; case (int)W32_DriveTypes.CompactDisc : idxicon = 5; break; case (int)W32_DriveTypes.RAMDisk : idxicon = 7; break; default: idxicon = 0; break; }
-
big noob problem :) i've got that public enum W32_DriveTypes : int { Unknown = 0, NoRootDirectory = 1, Removable = 2, LocalDisk = 3, NetworkDrive = 4, CompactDisc = 5, RAMDisk = 6 } and for my switch to wroks i need to put (int) in front ... ?! switch( int.Parse(mo["DriveType"].ToString()) ) { case (int)W32_DriveTypes.Removable : idxicon = 8; break; case (int)W32_DriveTypes.LocalDisk : idxicon = 4; break; case (int)W32_DriveTypes.NetworkDrive : idxicon = 6; break; case (int)W32_DriveTypes.CompactDisc : idxicon = 5; break; case (int)W32_DriveTypes.RAMDisk : idxicon = 7; break; default: idxicon = 0; break; }
The C# compiler does not understand that the Enum got a type. ;) You can save a few cast operations like that: W32_DriveTypes driveType = (W32_DriveTypes) int.Parse(mo["DriveType"].ToString()); switch( driveType ) { case W32_DriveTypes.Removable : idxicon = 8; break; case W32_DriveTypes.LocalDisk : idxicon = 4; break; case W32_DriveTypes.NetworkDrive : idxicon = 6; break; case W32_DriveTypes.CompactDisc : idxicon = 5; break; case W32_DriveTypes.RAMDisk : idxicon = 7; break; default: idxicon = 0; break; } _________________________________ Vote '1' if you're too lazy for a discussion