相关疑难解决方法(0)

在 C# 中,如何像枚举一样使用结构?

我有一个我想像枚举一样使用的结构:

public struct SQLDS_statementTypes
{
    public static string Select = "Select", 
        Update = "Update", Insert = "Insert", Delete = "Delete";
}
Run Code Online (Sandbox Code Playgroud)

但它抛出一个错误: “运算符'=='不能应用于'SQLDS_statementTypes'和'string'类型的操作数”在这个语句中:

if (statement == SQLDS_statementTypes.Update)
Run Code Online (Sandbox Code Playgroud)

有没有办法解决这个问题?

c#

3
推荐指数
1
解决办法
6524
查看次数

标签 统计

c# ×1