Hi, i would like to know whether this code can be improved. because each time i convert extremely long strings, my exe hangs (does not respond).
TIA
Code:
private string HexString2Ascii(string HexString) { StringBuilder Sb = new StringBuilder(); for (int i = 0; i <= hexTextBox.Text.Length - 2; i += 2) { Sb.Append(Convert.ToString(Convert.ToChar(Int32.Parse(HexString.Substring(i, 2), System.Globalization.NumberStyles.HexNumber)))); } return Sb.ToString(); } private void hexToAsciiButton_Click_1(object sender, EventArgs e) { try { asciiTextBox.Text = HexString2Ascii(hexTextBox.Text); } catch { MessageBox.Show("Invalid Input", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
Comment