471,327 Members | 2,595 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,327 software developers and data experts.

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

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

Jan 16 '06 #1
3 2254
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SammyBar" <sa******@gmail.com> wrote in message
news:O3**************@tk2msftngp13.phx.gbl...
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

Jan 16 '06 #2
"SammyBar" <sa******@gmail.com> wrote in news:O3anzesGGHA.3728
@tk2msftngp13.phx.gbl:
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
Jan 16 '06 #3
> public NombreValorList() : base()
{
}


Yes! It is evident... Sorry for your time and thanks a lot!
Sammy
Jan 16 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Simon | last post: by
3 posts views Thread by pantalaimon | last post: by
6 posts views Thread by Justin | last post: by
3 posts views Thread by J.J. Feminella | last post: by
2 posts views Thread by Sathyaish | last post: by
12 posts views Thread by st_ev_fe | last post: by
4 posts views Thread by Fedor Semenov | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.