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

2019-04-03 10:20发布

问题:

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#?

回答1:

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


标签: c++-cli