Osc*_*ros 9 c# parameters enums parameter-passing
我想知道以下是否可行:
该方法Regex.Match可以接收枚举,所以我可以指定:
RegexOptions.IgnoreCase
RegexOptions.IgnorePatternWhiteSpace
RegexOptions.Multiline
Run Code Online (Sandbox Code Playgroud)
如果我需要指定的不仅仅是一个,该怎么办?(例如,我想要我的正则表达式Multiline,我希望它忽略模式空白).
我可以|在C/C++中使用运算符吗?
dec*_*one 20
您需要使用[Flags]属性注释它并使用|运算符来组合它们.
在你提到的情况下,你可以这样做,因为RegexOptions枚举是用它注释的.
定义:
[FlagsAttribute]
public enum NewsCategory : int
{
TopHeadlines =1,
Sports=2,
Business=4,
Financial=8,
World=16,
Entertainment=32,
Technical=64,
Politics=128,
Health=256,
National=512
}
Run Code Online (Sandbox Code Playgroud)
使用:
mon.ContentCategories = NewsCategory.Business |
NewsCategory.Entertainment |
NewsCategory.Politics;
Run Code Online (Sandbox Code Playgroud)