using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace _05标志枚举
{
class Program
{
static void Main(string[] args)
{
//FileInfo info = new FileInfo(@"c:\hello.txt");
//Console.WriteLine(info.Attributes);
//info.Attributes = FileAttributes.ReadOnly | FileAttributes.Hidden | FileAttributes.Archive | FileAttributes.Compressed;
////=========================================================
// //UserState state = UserState.Busy;
// //为标志枚举赋值
// GoodPeople lyh = GoodPeople.白 | GoodPeople.富 | GoodPeople.高 | GoodPeople.帅;
// //验证lyh的枚举中是否具有白,这一项。
// if ((lyh & GoodPeople.白) == GoodPeople.白)
// {
// Console.WriteLine("小伙子很白!");
// }
// else
// {
// Console.WriteLine("不白!");
// }
// Console.WriteLine(lyh);
// Console.ReadKey();
//====================================判断一个文件是否隐藏===================
FileInfo info = new FileInfo(@"c:\hello.txt");
if ((info.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
{
Console.WriteLine("文件时隐藏的!");
}
else
{
Console.WriteLine("不隐藏!!!");
}
Console.ReadKey();
}
}
[Flags]//标志枚举,加上这个特性后枚举类型.ToString()返回的就是文字形式,不是数字了。
public enum GoodPeople
{
高 = 1,
富 = 2,
帅 = 4,
白 = 8,
美 = 16
}
//默认枚举都是使用int来替代的,但是也可以指定具体的数据类型。
//枚举:byte表示,限制类枚举中的数字类型。
public enum UserState : byte
{
//一般枚举中的每个值都是互斥的。
QMe,
OnLine = 100,
OffLine,
Busy,
Hide = 250,
Left //离开
}
}