Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
for example if i have a main string of
string str1="a b c e f g h i j k l m n o p q r, s t u v w x y z";

i want output as

str2="a b c e f g h i j k l m n o p q r";
str3="s t u v w x y z";


i want code for my question
Posted

so you have a string and want to perform some operations on it? You know what, .NET has a string class, how about reading some of its documentation?

And even better, did you consider buying a book on C# and studying that, it would teach you everything you should know when starting to use a new language.

:)
 
Share this answer
 
This is good that you want the code for this. But did you try a bit to get what you want? What would you do if someone writes this code for you?

Don't you know there is a method called Substring that easily serves your purpose. Please try the substring method and let us know if you get any difficulty.

Please post the difficulty. Dont forget. :-D
 
Share this answer
 
Since you are posting a programming question, how about acting like a programmer? What is it that you need to do?

Step 1, Find the comma.
Step 2, Store everything before the comma in str2
Step 3, Store everything after the comma in str3

So, what is available for you to do this? What is a string made up of? Isn't it an array of char?

So, can't you go one by one through the array until you find the comma?

Once you've found it, then what?

This is such a basic process that if you are having trouble with this, you need to take a formal class. If you are in a formal class, then you need to arrange for a tutor. When I was in college, I was a tutor, and one, it helps you out, and two, it helps them out by giving them money.
 
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