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 \u
escape. So const string IdDisplayName = "Clements\u2122 \u2116";
should get you what you want.
I assume that simply:
const string NoChar = "\x2116"; //№ - Unicode char 8470
const string TmChar = "\x2122"; //™ - Unicode char 8482
const string IdDisplayName = "Clements" + TmChar + " " + NoChar;
Is unacceptable?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With