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

  • SEARCH
  • Home
  • 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 8466463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:21:04+00:00 2026-06-10T15:21:04+00:00

I have a class like: public class boolMessage { public bool Message { get;

  • 0

I have a class like:

 public class boolMessage
{
    public bool Message { get; set; }
    public ResponseType Resp { get; set; }

    public boolMessage(bool _Message, ResponseType _Resp)
    {
        Message = _Message;
        Resp = _Resp;
    }
}

What i want to do is to create a class something like:

 public class listMessage
{
    public List<T> Message { get; set; }
    public ResponseType Resp { get; set; }

    public listMessage(List<T> _Message, ResponseType _Resp)
    {
        Message = _Message;
        Resp = _Resp;
    }
}

I think i can do with something like Generic Classes. I have googled it open lot of pages but not able to find some easy solution.

Why i required is like i want to return a array of object that are of different types like Student[] or Teacher[].

These classes like Teacher are generated by Entity Framework.

I would like to return some additional information with them …

Any help is appreciated

  • 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-10T15:21:06+00:00Added an answer on June 10, 2026 at 3:21 pm
      class ListMessage<T> {
         ...
      }
    

    Further comments:

    1. The name of your constructor in ListMessage is wrong.
    2. You should not expose member variables to the outside.

    With regard to 2., I would do the following:

    class ListMessage<T> {
       private List<T> _messages;
       public IEnumerable<T> Messages { get { return _messages; } }
    
       public ListMessage (IEnumerable<T> messages) {
          this._messages = messages.ToList ();
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class like this public class TestData { public string Name {get;set;}
I have a class like public User class { public string Name{get;set;} public string
I have a class like this: public class Contest { List<ContestTeam> Teams { get;
i have a class like [Serializable] public class MyClass { [XmlAttribute] public bool myBool
I have a class like that public class Tbl { public List<Row> Rows {get;
I have a class like this public class HistoryEntry { DateTime Date{ get; protected
i have a class like below public class Foo<T> { public List<T> Items{ get;
I have a class like that: public class Customer { public string Name {get;
I have a class like so: public class ClassA { public bool MethodA() {
i have a Class like public class user { public int ID { get;

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.