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

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

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

 
0
  #1
Apr 26th, 2009
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?
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 83
Reputation: nmaillet is an unknown quantity at this point 
Solved Threads: 18
nmaillet nmaillet is offline Offline
Junior Poster in Training

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

 
1
  #2
Apr 26th, 2009
Try str.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); .
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

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

 
0
  #3
Apr 26th, 2009
Originally Posted by nmaillet View Post
Try str.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); .
if that works i will kiss you on your forehead.
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

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

 
0
  #4
Apr 26th, 2009
wow it worked :

  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.
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 83
Reputation: nmaillet is an unknown quantity at this point 
Solved Threads: 18
nmaillet nmaillet is offline Offline
Junior Poster in Training

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

 
0
  #5
Apr 26th, 2009
I found it in the class library reference at the MSDN. http://msdn.microsoft.com/en-us/library/ms229335.aspx
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

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

 
0
  #6
Apr 26th, 2009
do you also know how to deselect all rows in a windows application?
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

datagridview deselect all rows

 
0
  #7
Apr 26th, 2009
i found it :

  1. foreach (DataGridViewRow dr in DataGridName.SelectedRows)
  2. {
  3. dr.Selected = false;
  4. }
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC