2009-11-11 91 views
1

我想知道是否存在可用於C#的命名空間,造成該類來自:CompilerServices.Operators等同於C#

Microsoft.VisualBasic.CompilerServices 

因爲我想要做這樣的事情,但在C#:

Dim m = GetType(CompilerServices.Operators).GetMethod("LikeString") 

由於

+0

這將是使用了反射porpouses – 2009-11-11 19:58:26

回答

2

當然可以做,沒有麻煩。您必須在C#項目中引用VisualBasic程序集。

var m = CompilerServices.Operators.GetType().GetMethod("LikeString"); 
0

LikeString是用於通過在VB中Like操作者的方法。有沒有在C#中沒有相應的操作,但你可以使用IsMatch來實現類似的功能:

bool bResult = Regex.IsMatch("some input string", "[a-z]*"); 
+0

他的問題很困惑,我不知道,如果你對這個問題還是我的打算是什麼,他一直在尋找... – 2009-11-11 18:50:35