如何声明常数的Guid在C#中? [英] How to declare a constant Guid in C#?

查看:622
本文介绍了如何声明常数的Guid在C#中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在C#中声明一个常量的Guid?

Is it possible to declare a constant Guid in C#?

我知道我可以声明静态只读的Guid ,但有一个语法,让我写常量的Guid

I understand that I can declare a static readonly Guid, but is there a syntax that allows me to write const Guid?

推荐答案

没有。在常量修改仅适用于原始类型(布尔,整型,浮点,双,长,小数,总之,字节)和字符串。基本上,任何你可以声明为文字。

No. The const modifier only applies to "primitive" types (bool, int, float, double, long, decimal, short, byte) and strings. Basically anything you can declare as a literal.

这篇关于如何声明常数的Guid在C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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