Calling base class default constructor when the base is a generic...

  • Thread starter Thread starter SammyBar
  • Start date Start date
S

SammyBar

I'm trying to inherit from a Generic class but I'm having troubles on the
syntax on how to specify a base constructor for my default constructor. I
want to do something like this:

public class NombreValorList : Dictionary<int, String>
{
public NombreValorList() : Dictionary<int,String>()
{
}
}

But the compiler wants the "base" keyword included.

Which is the correct syntax in this case?

Thanks in advance

Sammy
 
Sammy,

Well, I don't think that you have a choice. If the compiler wants the
"base" keyword, then it's going to get it. It's not going to output IL any
other way. =)

To that end, you need to do:

public class NombreValorList : Dictionary<int, String>
{
public NombreValorList() : base()
{
}
}

Hope this helps.
 
public class NombreValorList : Dictionary<int, String>
{
public NombreValorList() : Dictionary<int,String>()
{
}
}

But the compiler wants the "base" keyword included.

Which is the correct syntax in this case?

public NombreValorList() : base()
{
....
}

-mdb
 
Back
Top