Can you create abstract function as Static?
A static member cannot be marked as override, virtual, or abstract.
Can you create static function in Abstract class?
Yes.
Example:
A static member cannot be marked as override, virtual, or abstract.
Can you create static function in Abstract class?
Yes.
Example:
namespace ConsoleApplication2
{
public abstract class ps
{
public ps()
{
}
public ps(string a)
{
}
public abstract string getMessage();
public static void Helloworld() { Console.WriteLine("hello"); }
//A static member cannot be marked as override, virtual, or abstract
//public static abstract void Helloworld() { Console.WriteLine("hello"); }
//public static abstract string GetName();
}
public class Program :ps
{
static void Main(string[] args)
{
Program p = new Program();
Console.WriteLine(p.getMessage());
Helloworld();
Console.Read();
}
public override string getMessage()
{
return "message hello.";
}
}
}
Is it required to override all abstract function in derived class?
Yes
0 comments:
Post a Comment