Partager via


C++/CLI equivalent of the C# const keyword

Writing this just post because searching the string "C++/CLI" const equivalent on a search engine did not find what I was looking for.

The answer is, by the way, "literal"

[Guid(MyClass::Guid)]
ref class MyClass
{
   public:
   literal String^ Guid = "6C46D25A-BB4C-4bf9-8B26-F78D98C4BC18";
}

(initonly which is the equivalent of readonly in C++/CLI will not work because it would not be usable as a parameter to an attribute).

Comments

  • Anonymous
    July 15, 2006
    PingBack from http://microsoft.wagalulu.com/2006/07/15/ccli-equivalent-of-the-c-const-keyword/

  • Anonymous
    July 20, 2006
    I recently posted about the C++/CLI equivalent keyword for the C# const. Reason for the post was that...

  • Anonymous
    December 01, 2007
    Thanks, picked you up from Google - lifesaver.

  • Anonymous
    December 22, 2009
    First of all. Thanks very much for your useful post. I just came across your blog and wanted to drop you a note telling you how impressed I was with the information you have posted here. Please let me introduce you some info related to this post and I hope that it is useful for community. There is a good C# resource site, Have alook http://CSharpTalk.com Thanks again Rahul