You must Sign In to post a response.
  • Category: ASP.NET

    C# Array

    my input in string=("INDIA")
    and i need to get it in this manner("I","N","D","I","A")

    and this mtd is not working

    string str ="INDIA";
    char[] chrIndia = str;
  • #587311
    Hi,

    Try this

    string str ="INDIA";
    char[] chrIndia = str.ToCharArray();

    Regards,
    Danu

  • #587312
    Please the code.

    String.ToCharArray is used to split string to chars.


    protected void button1_Click(Object Sender,EventArgs e)
    {

    string myinput = "INDIA"
    char [] mychars = myinput.ToCharArray();
    Label1.Text = mychars[0].ToString();
    }



    hope this helps

    Thanks
    Prem

  • #587343
    Hi Buddy this code which i tried and it is working

    plz try this n let me know

    string strName = "Hello";
    char[] ch = strName.ToCharArray();
    Response.Write(ch[0]);

  • #587404
    try this code


    string final = "";
    string str = "INDIA";
    char[] strarray= str.ToCharArray();
    for (int i = 0; i < strarray.Length;i++ )
    {
    final+= "'"+strarray[i]+"'";
    }


    hope this will help you


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.