When I try this (with std::string in place of the CString though, because I don't have MFC here), I get an error C2864. It only works for me with TestConst at file scope (however, you may put it into a namespace).
error C3887: 'StyleConstNet::TestConst: the initializer for a literal data member must be a constant expression
Unfortunately this is the plain truth. The initializer for a literal member must be a compile-time constant. The CString, however, is an object that needs to be constructed at runtime, so it doesn't work that way. (And I'm not even sure you actually can simply assign a CString to a .NET System::String ^ at all, even away from the context of initialization.)
If you really don't want to write the constant twice in your code (which I can understand because it complicates maintainance), I think the adequate solution here is a really trivial one, #define the string literal as s macro:
Bookmarks