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 9294451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:22:32+00:00 2026-06-18T21:22:32+00:00

NOTE: .NET Pad code HERE . I have a base class that takes a

  • 0

NOTE: .NET Pad code HERE.

I have a base class that takes a generic type parameter.

Each class it will form the base of has a corresponding Collection Class which consists of only this:

public class List_SomeType : List<SomeTime> {
  public List_SomeType() {
  }
}

That’s it: It only a List<T> container.

However, it is posing a problem in my base class because one of the methods is to return this collection.

I tried creating the following Get method, which made perfect sense to me:

public TList Get() {
  var list = new TList();
  using (var cmd = new SqlCommand(SP_GET, m_openConn)) {
    cmd.CommandType = CommandType.StoredProcedure;
    using (var r = cmd.ExecuteReader()) {
      while (r.Read()) {
        list.Add(FillDataRecord(r));
      }
    }
    cmd.Connection.Close();
  }
  return list;
}

public class TList : List<T> {
  public TList() { }
}

In my derived class, I planned to call this base class as follows:

public class BuyerDB : DAL_Base<Buyer> {

  private static BuyerDB one;

  static BuyerDB() {
    one = new BuyerDB();
  }

  public static BuyerList GetBuyerList() {
    return (BuyerList)one.Get(); // <= ERROR HERE!
  }

}

The ERROR HERE states:

Cannot convert type ‘DAL_Base.TList’ to ‘BuyerList’

How do I convert back to a collection of my generic types?

EDIT:

Mark wants to know what BuyerList is.

I thought that was understood from what I wrote.

Apparently not, so here it is:

public class BuyerList : List<Buyer> { }

That’s all!

  • 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-18T21:22:33+00:00Added an answer on June 18, 2026 at 9:22 pm

    This compiles:

    public static BuyerList getBuyerList() {
      var result = new BuyerList();
      result.AddRange(one.Get());
      return result;
    }
    

    I am not sure why the other list would not work, but I’d guess it has something to do with checks done inside of the C# language.

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

Sidebar

Related Questions

NOTE: I'm working in .NET 3.5 here. Let's say I have sample base/child classes
Note that I'm aware of other yield in vb.net questions here on SO. I'm
I have an old school ASP (note: not ASP.NET) web site that has a
The following JavaScript code: alert(2 .x); Alerts 'undefined' (See it here: http://jsfiddle.net/Rp4wk/ ) (Note:
I found the following claim in the documentation for Net::OpenSSH : Note that using
[NOTE: I'm using ASP.NET MVC2 RC2.] I have URLs like this: /customers/123/orders/456/items/index /customers/123/orders/456/items/789/edit My
Does .NET Transliteration library exists ? Note that this is not translation, something like
Going a little insane here. Here is the jsfiddle: http://jsfiddle.net/mersenneprimes/CvGKK/ Note business is in
Please note that my experience in Silverlight/.Net and WCF is about two weeks of
See the jsfiddle here: http://jsfiddle.net/x7N66/3/ See the screenshot here: https://i.stack.imgur.com/dC9Gp.png Note the white band

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.