Click here to Skip to main content
15,908,841 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi friends

i want to split a long word like
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

this into
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa


like this

please give me a proper answer
Posted
Updated 30-May-13 23:30pm
v2

You can't do it well with your example, because it contains an odd number of characters in the input and an even number in the output, but the basic principle is:
C#
string longWord = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
string firstPart = longWord.Substring(0, longWord.Length / 2);
string secondPart = longWord.Substring(longWord.Length / 2);
 
Share this answer
 
Comments
sreeCoderMan 31-May-13 6:35am    
actually u are correct one more thing i have to tell u .
the aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
is not static actually that value is entered by user in textbox.

i need only maximum 20 letter in one line and the rest letter in next line how that possible
OriginalGriff 31-May-13 6:51am    
Look at the definition of String.Substring:
http://msdn.microsoft.com/en-us/library/system.string.substring.aspx
All you have to do is change the "longWord.Length / 2" part to the number of characters you want: 20
As far as the value to split is concerned: I guessed. Just use the TextBox.Text property :laugh:
in .net use substring method.
 
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