Logo 
Search:

C# Forum

Ask Question   UnAnswered
Home » Forum » C#       RSS Feeds

Error: 'TestCmd.Foo.Response()' is a new virtual member in a sealed class 'TestCmd.Foo'

  Asked By: Joel    Date: Oct 01    Category: C#    Views: 2087
  

I am getting following error any idea, what could be the possible cause.

class Class1
{
[STAThread]
static void Main(string[] args)
{
Foo b1 = new Bar();
b1.Response();
Console.ReadLine();
}
}
sealed class Foo
{
public virtual void Response()
{
Console.WriteLine("In Foo");
}
}
//Output
//Error: 'TestCmd.Foo.Response()' is a new virtual member in a sealed class 'TestCmd.Foo'

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Hattie Howard     Answered On: Oct 01

Is it because question is incorrect?

Someone told me sealed class  is final class and you cannot inherit it further and virtual  keyword is contradictory, as it can be overridden in child class and that is reason i am receiving this error.

 
This post is locked for further answers.




Tagged: