The problem is not that you cannot add an extension method to an abstract class (you can - you can add an extension method for any type) - it is that you cannot add a static method / strong> to a type with extension methods.
- , # . . , , :)
, , , .
, , Silverlight ( - )
- , - , , ( object, ):
public static class ExtraObjectStatics
{
public static void NewStaticMethod()
{
}
}
public class Test
{
public void foo()
{
object.NewStaticMethod();
ExtraObjectStatics.NewStaticMethod();
}
}
- , , , 2, ; .
( , ), Enum :
namespace MySystem
{
public class Enum
{
public static string[] GetNames()
{
}
}
}
- , , :
using System;
using MySystem;
namespace MyCode
{
public class TestClass
{
public static void Test()
{
Enum.GetNames();
}
}
}
"", "MySystem" , Enum.
:
using System;
namespace MyCode
{
using MySystem;
public class TestClass
{
public static void Test()
{
Enum.GetNames();
}
}
}
( ) Enum , , using .
, Enum , using MySystem;.
: System.Enum MySystem.Enum - , System.Enum.
, - Enum System.Enum - , System.Enum.
GetNames Reflector - , , ... , Silverlight.