代码之家  ›  专栏  ›  技术社区  ›  Jonathan Escobedo

compilerServices.operators等价于c#

  •  1
  • Jonathan Escobedo  · 技术社区  · 15 年前

    我想知道是否存在可用于c_的命名空间,因为此类来自:

    Microsoft.VisualBasic.CompilerServices
    

    因为我想做这样的事,但在C中:

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

    谢谢

    2 回复  |  直到 15 年前
        1
  •  2
  •   Frank Krueger    15 年前

    当然,它可以毫无困难地做到这一点。您必须在C项目中引用VisualBasic程序集。

    var m = CompilerServices.Operators.GetType().GetMethod("LikeString");
    
        2
  •  0
  •   Darin Dimitrov    15 年前

    LikeString 是由 Like VB中的运算符。在C中没有等价的运算符,但您可以使用 IsMatch 要实现类似功能:

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