C#枚举与保留关键字关键字

2023-09-04 00:52:36 作者:该昵称回复后可见

我是从我的工作打开旧的C#code,我发现,有一个SQL类枚举它是这样的:

I'm opening old C# code from my work and I found out that there was an enum in an SQL class which looked like this:

public enum Column
        {
            dateTime,
            binary,
            bool,
            autoIncrement
        }

这是从库中另一个人,是不是再到处用来成功地构建SQL querys。你可以看到,枚举填充了列类型。关键是,我不能编译,由于布尔是在C#中保留关键字。如果一切工作,如果我加双引号为bool?

It's from a library another person that is not longer around used succesfully to build sql querys. You can see that the enum is populated with column types. The thing is, I cannot compile that due to "bool" being a reserved keyword in C#. Should everything work if I add doublequotes to bool?

任何想法?

由于一吨!

推荐答案

您需要preFIX一个字符文字( @ 符号),以使用关键字

You need to prefix with a character literal (@ symbol) in order to use keywords.

MSDN (感谢@erikH)

MSDN (Thanks @erikH)