PC Review


Reply
Thread Tools Rate Thread

C# if string match found boolean - streamlined code?

 
 
jason@cyberpine.com
Guest
Posts: n/a
 
      29th Aug 2006
Though this code appears to work, I suspect it could be streamline.
Total Noob Here.


public bool isit(string c1)
{
string color1 = "blue green red";
Regex re = new Regex("@"+c1, RegexOptions.IgnoreCase |
RegexOptions.Multiline);
if (re.Matches(color1).Count > 0)
{
return (true);
}
else
{
return (false);
}


==
I found a sample on the net that does this

if (re.color1 != 0 )

But I get an error about Regex not having a definition for color1

==
Also, what if color1 was an enum, how would test the search string can
be found in any of the items?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search folder for string and open file is match found Maver1ck666 Microsoft Access VBA Modules 6 29th Sep 2009 03:40 PM
string/regex: extracting the context of a string match around the found search term? Microsoft C# .NET 3 5th Jul 2007 02:55 PM
C# if string match found boolean - streamlined code? jason@cyberpine.com Microsoft C# .NET 5 30th Aug 2006 02:56 AM
NotSupportedException Type.GetType (String, Boolean, Boolean) jonfroehlich Microsoft Dot NET Compact Framework 1 20th Apr 2006 02:44 PM
Code for no match found? el zorro Microsoft Access Form Coding 4 10th Nov 2004 05:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:39 AM.