J
Jose Fernandez
Hello
I have been reading about the differences between virtual and abstract
keywords...
What i understand is that with VIRTUAL keyword, you can actually write the
whole method and override it if needed... with abstract, you just declare
the method name and must write the code in the inherited class. Am I right??
public class House{
public House(){}
public virtual string GetHouseName()
{
return "This is the House name Method"; // Virtual method implemented
}
public abstract string GetHouseNumber(); // Abstract method not implemented
}
public class DogHouse : House
{
public DogHouse(){}
public override string GetHouseName()
{
return "This is the override GetHouseName method";
}
public override string GetHouseNumber()
{
return "This is the number overrided method";
}
}
I have been reading about the differences between virtual and abstract
keywords...
What i understand is that with VIRTUAL keyword, you can actually write the
whole method and override it if needed... with abstract, you just declare
the method name and must write the code in the inherited class. Am I right??
public class House{
public House(){}
public virtual string GetHouseName()
{
return "This is the House name Method"; // Virtual method implemented
}
public abstract string GetHouseNumber(); // Abstract method not implemented
}
public class DogHouse : House
{
public DogHouse(){}
public override string GetHouseName()
{
return "This is the override GetHouseName method";
}
public override string GetHouseNumber()
{
return "This is the number overrided method";
}
}