Click here to Skip to main content
15,938,122 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hi ,
give me a program to accept the string and split the input string by count by 2.
for ex:input string is"Indiana"
the output is:In,nd,di,ia,an,na
Updated 7-Dec-10 1:12am

That's not a doubt, yours is a shameless 'gimmecode' request.
The powerful .NET String class provides all methods you need for completing such a simple task.
Hint: Have a look at Substring method[^].
Share this answer
Look for loops and string method substring
Share this answer
it's quite simple my dear , no need for functions ... this is my advice to improve ur programming skills .

here u are :

see the result of ur Example here :[^]

the code :

<pre lang="cs">private void button1_Click(object sender, EventArgs e)
           int size;
           string word = textBox1.Text;
           size = word.Length;
           char[] array = new char[size];
           array = word.ToCharArray();
           if (size % 2 != 0)
               size += 1;
           for (int i = 0; i < size-2; i += 2)
               textBox2.Text += array[i].ToString() + array[i + 1].ToString() + ",";

this is the source code :

good luck :)
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900