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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:01:34+00:00 2026-05-11T07:01:34+00:00

If you have a custom collection class that stores the weights of a single

  • 0

If you have a custom collection class that stores the weights of a single class of fruits individually in floats/double, like so:

1.1, 3.3, 6.6, 4.4, ... 

and you would need to specify whether it’s float or double and to differentiate the fruit type, is it better to do it like this:

Using an enum:

FruitList<float, FruitType.Orange> 

or

Using an enum in the constructor:

FruitList<float> (FruitType.Orange) 

or

Using a class:

FruitList<float, Orange> 

or

Using a class in the constructor:

FruitList<float> (Orange) 

Thing thing that confuses me is whether specifying these kind of stuff makes sense in the <> area (don’t know what that area is called)?

Which is the better, faster, more efficient practice?

Btw the Orange class is never used anywhere, just wrote it if that would make sense to specify the type like that?

EDIT: Btw this is just an example case, not the actual one, but this reflects in a clear way. Like it’s all floats/doubles and are passed to some other methods. But the methods need to know what type of fruit to perform correctly. The fruit themselves mean nothing.

  • 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. 2026-05-11T07:01:34+00:00Added an answer on May 11, 2026 at 7:01 am

    First of all, enum values are not types, so the example

    FruitList<float, FruitType.Orange> 

    won’t work. If you want to ensure that your generic list is staticly typed to Orange you will have to use this one

    FruitList<float, Orange> 

    even though you will never use the Orange class. As I see it, there probably isn’t a need, since you can convey type in the variable name:

    FruitList<float> orangeWeights = new FruitList<float>(FruitType.Orange); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom collection class that I am trying to bind to
I'm writing a custom ASP.NET webcontrol and would like it to have a collection
Background I have a custom collection that is binded to the datagridview this.datagridview.DataSource =
I have a WCF service that needs to expose a custom collection to it's
I have this custom validation attribute for validating a collection. I need to adapt
I'm writing a plug-in for an application where I have a custom class that
I have a custom type MyClass and a factory class Factory that creates objects
The problem: I have a custom collection PagedList<T> that is being returned from my
So I have a custom ViewModel ( CompanySalaryDataViewModel ) that has a collection of
Aloha, I have a custom control that I need to instantiate from within a

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.