C#枚举与保留关键字 [英] C# Enums with reserved keywords

查看:222
本文介绍了C#枚举与保留关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是从我的工作打开旧的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)

这篇关于C#枚举与保留关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆