private voID cbInstallType_SelectedindexChanged(object sender,EventArgs e) { if (cbInstallType.Text == "Full Install") { eventFlags = GBFEvents.All; } else if (cbInstallType.Text == "DB Only") { eventFlags = (GBFEvents.InitGBFsql | GBFEvents.PerformDatabaseUpdate); } else if (cbInstallType.Text == "copy files Only") { eventFlags = GBFEvents.All; eventFlags &= ~(GBFEvents.InitGBFsql | GBFEvents.PerformDatabaseUpdate); } }
因此定义了GBFEvents:
public enum GBFEvents{ NONE = 0,InitGBFsql = 1 << 0,ServiceIISControlDown = 1 << 1,SetWebConfigValues = 1 << 2,ReadfileLists = 1 << 3,copyfiles = 1 << 4,FixWebConfigValues = 1 << 5,BuildAppPaths = 1 << 6,PerformDatabaseUpdate = 1 << 7,ServiceIISControlUp = 1 << 8,All = ~(-1 << 9)}解决方法 将其更改为单行是一个非常简单的例子,只是扩展了所做的事情.所以一步一步走:
var eventFlags = GBFEvents.All;eventFlags &= ~(GBFEvents.InitGBFsql | GBFEvents.PerformDatabaseUpdate);
如果我们扩展& =我们得到:
var eventFlags = GBFEvents.All;eventFlags = eventFlags & ~(GBFEvents.InitGBFsql | GBFEvents.PerformDatabaseUpdate);
如果我们在第二行中内联使用eventFlags,我们得到:
var eventFlags = GBFEvents.All & ~(GBFEvents.InitGBFsql | GBFEvents.PerformDatabaseUpdate);总结
以上是内存溢出为你收集整理的c# – 从.All中逐位减法全部内容,希望文章能够帮你解决c# – 从.All中逐位减法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)