I’m trying to extend Task class, but I get two different errors depending how I extend it:
first one:
public class ExtTask : Task
{
public static void DoSomenthing(this Task task)
{
//some code
}
}
Extension method must be defined in a non-generic static class
so I add static:
public static class ExtTask : Task
{
public static void DoSomenthing(this Task task)
{
//some code
}
}
getting error:
Static class ‘DownloadFile.ExtTask’ cannot derive from type ‘System.Threading.Tasks.Task’. Static classes must derive from object.
how can I solve this problem?
You don’t need to derive from task if you are trying to add an extension method, change it to