Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++/CLI equivalent of C#'s 'readonly' keyword

Tags:

What's the C++/CLI equivalent of C#'s readonly keyword?

Specifically, how do you write a public or protected member of a C++/CLI class such that it is readonly when referenced from C#?

like image 914
James Hopkin Avatar asked Sep 19 '11 10:09

James Hopkin


People also ask

Is .NET a C++?

The . NET framework can work with several programming languages such as C#, VB.NET, C++ and F#.

What is Gcnew in Visual C++?

gcnew is an operator, just like the new operator, except you don't need to delete anything created with it; it's garbage collected. You use gcnew for creating . Net managed types, and new for creating unmanaged types.

Is .NET similar to C++?

C++ is a object oriented programming language. But here . Net is a framework which supports multiple languages to build applications using . net class libraries which will be excueted via CLR .


1 Answers

I just found out (thanks to Literal field versus constant variable in C++/CLI) that

  • C# const is literal in C++/CLI, and
  • C# readonly is initonly in C++/CLI
like image 200
James Hopkin Avatar answered Sep 24 '22 00:09

James Hopkin