VB.NET Like Statement

  • Thread starter Thread starter Derrick
  • Start date Start date
D

Derrick

Is it possible to "Inline" VB code in a C# class? I need the Like
statement, regular expressions are different enough that we would like two
searching options, "Like" and Regexs.

If not, just create a simple VB.NET assembly?

Thanks in advance!

Derrick
 
Is it possible to "Inline" VB code in a C# class? I need the Like

I don't think so. They would need to change the csc compiler to allow that.
statement, regular expressions are different enough that we would like two
searching options, "Like" and Regexs.

There is a LIKE in the Select statement if using a ADO table. Not sure
about just on strings. I don't think you need both, you should be able to
abstract your Regex methods to give you all the "like'ness" you need. That
way you don't need other DLLs - just c# code.
Here is a quick example. You can make as fancy as you need. I don't know
all the VB syntax for Like, but you can get what you need using regex. HTH

//VB
//if ( stringA Like "%bill%tom% )

//- c# could be --
string stringA = "is bill and tom in this string?";
string pattern = "bill.*tom";
Regex rgx = new Regex(pattern);
if (rgx.IsMatch(stringA))
Console.WriteLine("Yes. Found match.");
else
Console.WriteLine("Did not find match.");
 
Back
Top