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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:47:55+00:00 2026-06-13T05:47:55+00:00

One hour ago I asked a question: how can I write an extension method

  • 0

One hour ago I asked a question: how can I write an extension method for Enum?-Nullable<Enum>
surprisingly I got an answer telling me I can write the extension method for Enum and it can be used for all enums and nullable enums.

Cool, it workes, but how?

If I understand correctly, all enums derive from Enum so this why I can use this extension method in every enum I have.

But… the ItemType? enum, for example, isn’t an enum, it’s Nullable<ItemType>, which doesn’t derives from ItemType nor Enum.
Just like List<DataReader> doesn’t derive from DataReader and thus can’t use DataReader methods, though DataReader is it’s Generic type.

I know The Nullable<T> type has a lot of “voodoo” and syntactic sugar, is this one of them?

  • 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-13T05:47:56+00:00Added an answer on June 13, 2026 at 5:47 am

    Extension methods do not require the class to be /derived/, they just require a conversion to exist (more specifically: an implicit identity, reference or boxing conversion; this is §7.6.5.2 “Extension method invocations”).

    The conversion from Nullable<ItemType> to System.Enum is a boxing conversion; same as a conversion from Nullable<int> to System.Object.

    And if you defined your own structure struct Test : IMyInterface {}, there would be a conversion from Nullable<Test> to IMyInterface.

    Boxing conversions from nullables will return a null reference if the nullable was null; and box the nullable’s value otherwise. For details see §6.1.7 “Boxing conversions” in the C# specification.

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

Sidebar

Related Questions

I have asked a similar question before and got an convincing answer as well?
What where clause can I use to select records that are one hour ago
after one hour googling, I can't find the right answer to the issue I'm
About an hour ago i asked a question on rails associations: Question on Proper
Until like one hour ago, I was convinced that in python Foo ().bar ()
Possible Duplicate: Given a time, how can I find the time one month ago
One hour ago, I spend a lot of time and finished the project but
My emulator and SDK package were working fine literally one hour ago. I try
I need a java.sql.Timestamp value corresponding to one hour ago. I have a few
I think my question must be really stupid, but I just spent one hour

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.