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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:17:57+00:00 2026-06-12T18:17:57+00:00

For the following generic class. class Message<T> { public enum TYPE { Heart, Spade

  • 0

For the following generic class.

class Message<T>
{
    public enum TYPE { Heart, Spade };
}

In Java, to refer to enum, I can simply

// Works in Java
Message.TYPE type = Message.TYPE.Heart;

But how about in C#? In C#, I need to provide a dummy type

Message<double>.TYPE type = Message<double>.TYPE.Heart;

Is there any way I can avoid the dummy type?

  • 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-12T18:17:58+00:00Added an answer on June 12, 2026 at 6:17 pm

    You can use the following code.

    abstract class Message
    {
       public enum TYPE { Heart, Spade };
    }
    
    class Message<T> : Message
    {
    
    }
    

    and then you can access TYPE like Message.TYPE type = Message.TYPE.Heart;

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

Sidebar

Related Questions

I have the following generic class: public class MessageProcesser<T> where T : Message Inside
I have the following generic repository: public class GenericRepository<TEntity> where TEntity : class {
Is it possible to create generic class as following? public class AnyClassTypeWithValue<Class<T>, E> {
I have the following code implementation of my generic singleton provider: public sealed class
I have the following generic question Here is a my generic message interface. public
I have a snippet code for instantiation of a generic type as following: public
I have the following class: public class Message { private String text; public String
I have the following model structure: class Container(models.Model): pass class Generic(models.Model): name = models.CharacterField(unique=True)
I have a model class similar to the following: using System; using System.Collections.Generic; using
I have the following base interface public interface IHandler{ void Handle(IMessage message); } and

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.