Logo 
Search:

C# Forum

Ask Question   UnAnswered
Home » Forum » C#       RSS Feeds

Cannot create an instance of the abstract class or interface

  Asked By: Madeleine    Date: Jul 22    Category: C#    Views: 3353
  

I am getting following error: Cannot create an instance of the abstract class or interface

My Assignment code is as under.

class Class1
{
static void Main(string[] args)
{
Foo foo = new Foo();
Console.ReadLine();
}
}
abstract class Foo
{
public Foo()
{
Console.WriteLine("In Foo");
}
}
class Bar : Foo
{
public Bar()
{
Console.WriteLine("In Bar");
}
}
//Output
//Error: Cannot create an instance of the abstract class or interface 'TestCmd.Foo'

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Monique Perry     Answered On: Jul 22

Ohh, after reading theory chapters i come to know that we cannot instantiate abstract  class and that is the reason i am receiving above error  message.

 
This post is locked for further answers.




Tagged: