Search code examples
c#datatablecharis-empty

Check empty Char in a array C#


I'm reading a field On a table it only has 3 values ("",ESD,R&S)

I don't know exactly why, but when I read the R&S value, the print out label is R ("empty space") S this is the code I'm using:

char[] area = read1[8].ToString().ToCharArray();
// if array is less than one do nothing
if (area.Length > 1)
{
    //trying to use this to check if the second item of array is the "&" symbol (print this format data)
    if (area[1].ToString() == "&")
    {
        Arealbl.Text = area[0].ToString() + "\n" + "&" + "\n" + area[2].ToString();
    }
    //else print out this format data
    else
    {
        Arealbl.Text = area[0].ToString() + "\n" + area[1].ToString() + "\n" + area[2].ToString();
    }
}

I using this code because I haven't found an easy way to put a label on vertical.


Solution

  • The & is a special char in MenuItems, Labels and Buttons, used to indicate that the next char should be underscored. When you manage to focus Arealbl and hit Alt you might see that.

    Set

    Arealbl.UseMnemonic = false;
    

    somewhere. Like with the designer.