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
Posted
Updated 7-Dec-10 1:12am
v2

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
link[^]
 
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 :

http://www.m76at.com/upload/image17217.html[^]

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 :

http://www.zshare.net/download/836108228e67fdfd/


good luck :)
 
Share this answer
 
v4

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