RSS Forums RSS
Please support our C# advertiser: Programming Forums
Views: 434 | Replies: 1
Reply
Join Date: Jul 2007
Posts: 3
Reputation: FilteR is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
FilteR FilteR is offline Offline
Newbie Poster

Question a few days in C# and already needs helP

  #1  
Jul 27th, 2007
hello to all!!
my name is Alex, i started with progeamming a few days ago, now i got to do this console application and i dont know how i can find and compare one word inside a sentence:
fro example:
"Hello World!"
how can i check if the word "Hello" appears in the text?

for now i managed only to ceate something that compares if the string is identical or not, but thats not good enough.

i'm very new in this so i will apreciate the patiance!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2007
Posts: 321
Reputation: Hamrick will become famous soon enough Hamrick will become famous soon enough 
Rep Power: 3
Solved Threads: 33
Hamrick's Avatar
Hamrick Hamrick is offline Offline
Posting Whiz

Re: a few days in C# and already needs helP

  #2  
Jul 27th, 2007
Use the Contains method of the string class to find substrings.
  1. string s = "Hello World!";
  2.  
  3. if ( s.Contains( "Hello" ) ) {
  4. Console.WriteLine( "Found \"Hello\" in the string" );
  5. }
The truth does not change according to our ability to stomach it.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 6:29 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC