Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,
I need to split a string at sixth white space and store the splitted parts into two variables.How to do this.Any help will be really appreciated.

What I have tried:

Suppose the string is "Two Thousand Four Hundred Ninety Three Dirhams and Twenty Eight Fils " I need to split it at 6 th white space and store first and second splitted parts to two variables
Posted
Updated 20-Oct-17 19:57pm

Quote:
How to do this.Any help will be really appreciated.

There is no magic tool that will detect any condition you want, you have to build an algorithm to do this.
C# allow you to check any given char of a string against space, you have to device an algorithm that will detect a space, count them and give you the position of sixth.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.
 
Share this answer
 
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

So start by looking at either a Regex (Search for "Regular Expressions c#") and get a copy of Expresso[^] - it's free, and it examines and generates Regular expressions, or look at the string handling functions: string.Split, string.IndexOf, and string.Substring methods.

Try it yourself, you may find it is not as difficult as you think!
 
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