How to declare a constant Guid in C#?
问题 Is it possible to declare a constant Guid in C#? I understand that I can declare a static readonly Guid , but is there a syntax that allows me to write const Guid ? 回答1: 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. 回答2: Declare it as static readonly Guid rather than const Guid 回答3: public static readonly Guid Users = new Guid("5C60F693-BEF5-E011-A485-80EE7300C695");