How to declare a constant Guid in C#?

前端 未结 5 1791
暗喜
暗喜 2020-12-10 10:17

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

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-10 10:29

    While you can't seem to do that you can do that to be parsed whenever you need it:

    const string _myGuidStr = "e6b86ea3-6479-48a2-b8d4-54bd6cbbdbc5";
    

    But don't use the above guid as it belongs to me solely, I first generated it so I claim ownership on this particular guid above! But I'm generious - use this one instead (I don't like how it talks back to me but it's a nice guid overall when it keeps its mouth shut): 284c694d-d9cc-446b-9701-b391876c8394

提交回复
热议问题