我有一个类似以下的场景,我有一个枚举,我得到了一些经过解析的文本,以创建一个枚举列表,我想将其传递到ReportResults中,该列表将根据传递的标记来创建电子邮件。无法更改枚举或ReportResults方法,是否可以传递诸如resultflags变量之类的内容?有没有一种方法可以使用Enum.TryParse创建要传递的单个项目? (在某些情况下,序列化需要这样的东西)
[flags]
public enum Result
{
None = 0,Warning = 2,Error = 4,Success = 8,Failure = 16
}
public void ProcessResultvalues(string log)
{
var resultflags = new List<Result>();
/// Process log text,add Result flags to the resultflags list
ReportResults(resultflags);
}
public void ReportResults(Result results)
{
/// Based on the flags,generate a text to describe if the process succeeded or failed and if there were any warnings or errors encountered during processing.
}