View Code
1 // ============================================== ================================= 2 UserState state = UserState. busy; 3 // assigned 4 GoodPeople lyh = GoodPeople for the flag enumeration. white | GoodPeople. rich | GoodPeople. high | GoodPeople. shuai; 5 6 // verify whether the enumeration of lyh has white. 7 if (lyh & GoodPeople. White) = GoodPeople. White) 8 {9 Console. WriteLine ("young man is very white! "); 10} 11 else12 {13 Console. WriteLine (" not white! "); 14} 15 Console. WriteLine (state. ToString (); 16 17 Console. WriteLine (lyh); 18 Console. ReadKey ();
1 [Flags] // flag enumeration. With this feature, the enumerated type. ToString () returns the text format, not a number. 2 // if it is a number, add 3 public enum GoodPeople 4 {5 Height = 1, 6 rich = 2, 7 handsome = 4, 8 white = 8, $9 = 1610}
The above is the flag Enumeration
Determine whether the object is hidden (the meaning of the object)
1 FileInfo info = new FileInfo (@ "c: \ hello.txt"); 2 if (info. attributes & FileAttributes. hidden) = FileAttributes. hidden) 3 {4 Console. writeLine ("hidden when file! "); 5} 6 else 7 {8 Console. WriteLine (" Do not hide !!! "); 9} 10 Console. ReadKey ();