Displaying ampersand in form label - C#

c#

Solution

you need to escape it with use double ampersand `&&` for displaying single ampersand `&`

Note : single `&` has different meaning that it will be treated as `ACCESS KEY PREFIX` character and you need to escape it with another &

Try This :

&&

OR

you can set `UseMnemonic` property of the `label` to `false`, and give only `one` ampersand `&` .when you set `UseMnemonic` to `false` ampersand will be treated as normal literal and displayed.

Problem

If I build a simple string like this: ``` string myStr = "Kayla & William"; ``` And then simply set the label text on a form like this: ``` lbl_Phrase.Text = myStr; ``` The output in the form removes the ampersand (&) I've tried: - escaping the & - ASCII encoding - char.ConvertFromUtf32(38) When I debug and step through the code the string includes the `&` just fine. Also, I can write the string to `Debug.WriteLine(myStr);` and it looks great. Is the problem related to how the form displays the string? How can I get the label to display the `&`?

Original source

Related problems