📜  c# 扩展 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:09.911000             🧑  作者: Mango

代码示例1
public static class MyClassExtension
{
  // This is the method you are adding to a class "MyClass"
  public static string GetValue(this MyClass myClass)
  {
    return value.toString();
  }
}

// This is how you can use it in other parts of your code
MyClass myClass = new MyClass();
string s = myClass.GetValue();