If I try
const char NoChar = (char)8470; //№
const char TmChar = (char)8482; //™
const string IdDisplayName = "Clements" + TmChar + ' ' + NoChar;
it will throw a compile error:
The expression being assigned to ‘{0}’ must be constant
As far as I understand, this error occurs because when a char is because the string concatenation operator (+) internally calls ToString on the concatenated object.
My question is if there is a way (unmanaged?
) to do it.
I need to pass that constant as an attribute and it should be generated on client.
The uglier workaround (will see what’s uglier based on your answers…) is to subclass that attribute (which is sealed, will have to make some decompilation and copy-paste work) and embedding it as a non-const will be possible.
You’re allowed to specify unicode character values directly in a string via the
\uescape. Soconst string IdDisplayName = "Clements\u2122 \u2116";should get you what you want.