I have this piece of code, which is an event handler of a button1's click.
private void button1_Click(object sender, EventArgs e)
{
string str = "trj\0klk";
textBox1.Text =c.ToString() ;
}
As you can see in the previous code, i want to write "trj\0klk" string in the textBox1, but when i run this application, only "trj" appear in textBox1, because the compiler thought the character "\0" (the fourth character) is the null terminator character, so it stoped reading the string when reached it. How can I solve this problem?
Loading
Nilanka DharmadasaPosted Nov 9, 2009, 10:22 PM
This will work for you.
string str = "trj\\0klk";
textBox1.Text = str.ToString();
But I dont know it's what you want.
If this helps, please accept my answer.
Mohamed Sidi MohamedPosted Nov 9, 2009, 6:47 PM
\\0 and \0 are very different, when you put @ before the string, the textbox will read null character as two characters: backslash and '0' characters, and that 's not what i want.
Thanks.
Mohamed Sidi MohamedPosted Nov 9, 2009, 6:46 PM
\\0 and \0 are very different, when you put @ before the string, the textbox will read null character as two characters: backslash and '0' characters, and that 's not what i want.
Jorge L FernandezPosted Nov 9, 2009, 6:25 PM
Try this
string myValue = @"example\0next";
TextBox1.Text = myValue;
// Should show exaclty "example\0next"
Mohamed Sidi MohamedPosted Nov 9, 2009, 6:13 PM
Thanks.
My best wishes.
Jorge L FernandezPosted Nov 9, 2009, 5:11 PM
const string NULL = " ";
string theValue = "example\0next"
TextBox1.Text = theValue.Replace("\0",NULL);
// This Sample will show "example next"
This will solve your problem. Set the NULL variable with the char you want to represent in the control.