I am stuck with converting textbox string value to byte array.
For ex;
Textbox1.text="ABC";
converting to byte array as
byte[] array1;
array1[0]=65;
array1[1]=66;
array1[2]=67;
Then I want to write all array1 to Textbox2 as
Textbox2=656667
Shortly, Input is "ABC" Ouput is "656667".
I am working with below codes it gives error at
int value = Int32.Parse(arrText[i], System.Globalization.NumberStyles.Number);
sample code
string text = textBox1.Text + " ";// .Text + " ";
text.Trim();
string[] arrText = text.Split(' ');
byte[] data = new byte[arrText.Length];
for (int i = 0; i < arrText.Length; i++)
{
if (arrText[i] != "")
{
int value = Int32.Parse(arrText[i],
System.Globalization.NumberStyles.Number); //gives error
data[i] = (byte)Convert.ToByte(value);
}
}
for (int i = 0; i < arrText.Length; i++)
{
textBox2.Text += data[i].ToString();
}
No comments:
Post a Comment