public partial class _Default : System.Web.UI.Page
{
char[] chname1=new char[20];
char[] chname2=new char[20];
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btsubmit_Click(object sender, EventArgs e)
{
chname1 = Convert.ToChar(txtname1.Text);
chname2 = Convert.ToChar(txtname2.Text);
Response.Write(chname1.ToString().Length+"---"+chname2.ToString().Length);
}
}
This is a simple asp.net code,i cannot convert char to char array…
How to find the character at ch[i] th position?
You’ve got a string, and you’re trying to convert it to
char, and then assign the result to achar[]variable.Are you sure you don’t just want:
Note that calling
ToString()on achar[]probably doesn’t do what you want it to either… converting achar[]to astringis normally done vianew string(char[]).