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

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

问题描述

是否可以在 C# 中声明常量 Guid?

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

我知道我可以声明一个static readonly Guid,但是有没有一种语法可以让我编写const Guid?

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

推荐答案

没有.const 修饰符仅适用于原始"类型(bool、int、float、double、long、decimal、short、byte)和字符串.基本上任何你可以声明为文字的东西.

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.

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

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