Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9247497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:44:35+00:00 2026-06-18T09:44:35+00:00

In Pro C# by Andrew Tolson, the writer says that when a non generic

  • 0

In Pro C# by Andrew Tolson, the writer says that when a non generic class extends a generic base class, the derived class must specify the type parameter.

// Assume you have created a custom
// generic list class.
public class MyList<T>
{
  private List<T> listOfData = new List<T>();
}
// Non-generic classes must specify the type
// parameter when deriving from a
// generic base class.
public class MyStringList : MyList<string>
{}

What I don’t understand is why this is necessary?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:44:36+00:00Added an answer on June 18, 2026 at 9:44 am

    Well, non-generic classes do not have type parameters, and generic classes have one or more type parameter.

    If you inherit the class from a generic class, without specifying the type parameter, you still have a generic class, i.e

    public class MyList<T> : List<T> {} //MyList is still generic
    

    but

    public class MyList : List<T> {} //invalid declaration, what is T ?
    

    so

    public class MyStringList : List<string> {} //specified with string
    

    or, more general

    public class MyArrayList : List<object> {} //specified with object
    

    A more wordy explanation, mostly because I love using the word “arity“.

    Classes in the CLR can have arity of zero or more, meaning that they can specify zero or more type parameters. However, the CLR cannot instantiate classes with non-zero arity, so in order to do anything useful, the arity of the class must be brought down to zero.

    That means, that while we can partially specify classes like:

    public class IntKeyDictionary<TValue> : Dictionary<int, TValue>
    

    that decrease the arity, or even declare classes like

    public class ListAndAHalf<TOne, TTwo> : List<TOne>
    

    that increase the arity, the story has to end with a class with an arity of 0, like List<string>, Dictionary<int, double> etc…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Pro Git the author says that Git staging is just a file storing
I want to ask pro developers out there that how they manage a big
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
I have MacBook pro with Radeon HD6750, MacOS 10.7.5 and I found that it
I have a MacBook Pro that I'm trying to do some development on. I
Working through Pro ASP.NET MVC book and I got the following code snippet that
In his book Pro C# 2008 and the .NET 3.5 Platform , Andrew Toelsen
namespace Pro { class ErrorLog { public ErrorLog(RenderWindow app) { startTime = DateTime.Now.ToString(yyyyMMddHHmm); outFile
I wonder the pro / cons for below method to get a image: http://image.anobii.com/anobi/image_book.php?type=3&item_id=013c23a6dd4c6115e4&time=1282904048
I'm reading Pro C# 2010 and the .Net 4 Platform by Andrew Troelsen. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.