"David Anton" <Da********@discussions.microsoft.comwrote in message
news:B1**********************************@microsof t.com...
You have two alternatives:
1. static System::String ^ const foo = "a";
2. literal System::String ^foo = "a";
Note that the first alternative, minus the 'static', is the only way to
declare method-level string constants in C++/CLI.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"DaTurk" wrote:
>I'm converting MC++ to C++/CLI and for some reason it's not cool with
static const System::String^
How am I supposed to have static constant strings then?
That would be a handle to a constant String. .NET does not have a concept
of a syntactically immutable object, only by semantics of the implementation
are objects immutable (and Strings are pretty much immutable without needed
to specify const). What you want is a name that always refers to the same
String objects, that's a constant handle. Dave pointed out that you would
write that as "String^ const". That's still not compile-time constant, the
value must be loaded out of the declaring assembly at JIT time. Only the
literal keyword gives you true compile-time constness.