R
RP2691
Guest
I am trying to relearn C# and came across something today that does not make sense to me.
The methods in the below image are clearly extension methods (not only does the class name indicate that, but so do the method signatures - having 'this' with the first parameter). That's fine; I get extension methods in general.
The methods have no implementation, no curly braces, and end with a semicolon: as far as I know, that's a clear indication that they are abstract methods. That would be fine too, since I understand abstract methods. But the methods don't have the word abstract in their declaration, and neither does the class (if any method in a class is abstract, then the class has to be abstract also).
Maybe it has something to do with the extension methods being for an interface, IWebHost. But that doesn't seem to work (in my mind) because interface method declarations don't have access modifiers and cannot be static (these methods are public and static), and the enclosing entity is defined to be a class, not an interface.
Can someone please explain?
namespace Microsoft.AspNetCore.Hosting
{
public static class WebHostExtensions
{
public static void Run(this IWebHost host);
public static Task RunAsync(this IWebHost host, ...);
public static Task StopAsync(this IWebHost host, ...);
public static void WaitForShutdown(this IWebHost host);
public static Task WaitForShutdownAsync(this IWebHost host, ...);
}
}
Continue reading...
The methods in the below image are clearly extension methods (not only does the class name indicate that, but so do the method signatures - having 'this' with the first parameter). That's fine; I get extension methods in general.
The methods have no implementation, no curly braces, and end with a semicolon: as far as I know, that's a clear indication that they are abstract methods. That would be fine too, since I understand abstract methods. But the methods don't have the word abstract in their declaration, and neither does the class (if any method in a class is abstract, then the class has to be abstract also).
Maybe it has something to do with the extension methods being for an interface, IWebHost. But that doesn't seem to work (in my mind) because interface method declarations don't have access modifiers and cannot be static (these methods are public and static), and the enclosing entity is defined to be a class, not an interface.
Can someone please explain?
namespace Microsoft.AspNetCore.Hosting
{
public static class WebHostExtensions
{
public static void Run(this IWebHost host);
public static Task RunAsync(this IWebHost host, ...);
public static Task StopAsync(this IWebHost host, ...);
public static void WaitForShutdown(this IWebHost host);
public static Task WaitForShutdownAsync(this IWebHost host, ...);
}
}
Continue reading...