Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hey following is my code for dividing string into two parts. but my last digit may be more than 4 then what i do for that
C#
string aaa=TextBox1.Text;
string mode = aaa.Substring(0, 5);
string mlen = aaa.Substring(5, 4);
Posted
Comments
Thanks7872 23-Jan-15 1:44am    
Better solution can be applied here. Would you please post sample strings and required output for each of them?

Do away with the second argument, try this:
string mlen = aaa.Substring(5);
 
Share this answer
 
v2
Comments
Rajesh waran 8-Jan-15 0:33am    
My +5
Try like this,
C#
int len = aaa.Length;
string mode = aaa.Substring(0, 5);
string final_string = aaa.Substring(5, len);
 
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