943,771 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 3311
  • C# RSS
Apr 26th, 2009
0

what is the easiest way to get words in a string?

Expand Post »
i am creating a small cpu simulator and i need to parse the assembly instruction which is like "add $s1 $s2 $s3", i need to get these four individual words ignoring the white spaces, if i use string.split(' '), it wont work if user enters more than one space between the words. i think of implementing it using subscript, but there should be easier way.
any ideas?
Similar Threads
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Apr 26th, 2009
1

Re: what is the easiest way to get words in a string?

Try str.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); .
Reputation Points: 69
Solved Threads: 48
Posting Whiz in Training
nmaillet is offline Offline
203 posts
since Aug 2008
Apr 26th, 2009
0

Re: what is the easiest way to get words in a string?

Click to Expand / Collapse  Quote originally posted by nmaillet ...
Try str.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); .
if that works i will kiss you on your forehead.
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Apr 26th, 2009
0

Re: what is the easiest way to get words in a string?

wow it worked :

C# Syntax (Toggle Plain Text)
  1. string something = "ali veli deli";
  2. string[] somethings = something.Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries);
  3.  
  4. Response.Write(somethings.Length.ToString());
the output is 3 as expectedly.
now the question for you, how were you able to find this information?
Last edited by serkan sendur; Apr 26th, 2009 at 10:36 pm.
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Apr 26th, 2009
0

Re: what is the easiest way to get words in a string?

I found it in the class library reference at the MSDN. http://msdn.microsoft.com/en-us/library/ms229335.aspx
Reputation Points: 69
Solved Threads: 48
Posting Whiz in Training
nmaillet is offline Offline
203 posts
since Aug 2008
Apr 26th, 2009
0

Re: what is the easiest way to get words in a string?

do you also know how to deselect all rows in a windows application?
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Apr 26th, 2009
0

datagridview deselect all rows

i found it :

C# Syntax (Toggle Plain Text)
  1. foreach (DataGridViewRow dr in DataGridName.SelectedRows)
  2. {
  3. dr.Selected = false;
  4. }
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Videofile Manipulation
Next Thread in C# Forum Timeline: Database railway reservation system





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC