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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:52:34+00:00 2026-05-14T00:52:34+00:00

Googling is only coming up with the keyword, but I stumbled across some code

  • 0

Googling is only coming up with the keyword, but I stumbled across some code that says

MyVariable = default(MyObject);

and I am wondering what it means.

  • 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-05-14T00:52:35+00:00Added an answer on May 14, 2026 at 12:52 am
    • For a reference-type, it returns null
    • For a value-type other than Nullable<T> it returns a zero-initialized value
    • For Nullable<T> it returns the empty (pseudo-null) value (actually, this is a re-statement of the second bullet, but it is worth making it explicit)

    The biggest use of default(T) is in generics, and things like the Try... pattern:

    bool TryGetValue(out T value) {
        if(NoDataIsAvailable) {
            value = default(T); // because I have to set it to *something*
            return false;
        }
        value = GetData();
        return true;
    }
    

    As it happens, I also use it in some code-generation, where it is a pain to initialize fields / variables – but if you know the type:

    bool someField = default(bool);
    int someOtherField = default(int);
    global::My.Namespace.SomeType another = default(global::My.Namespace.SomeType);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I only want facts as far as possible. There are some things that ASP.Net
The subject line says it all. Googling DAL & DAO returns only C# .NET
Googling has been difficult because I can't get results specific enough - wondering if
Googling this does little good, as you can imagine. Does anyone have resources that
While googling, I see that using java.io.File#length() can be slow. FileChannel has a size()
After googling i came to know that Index seek is better than scan. How
Aight, did a bit of Googling and searching here, the only question I found
Coming from a C++ background, I'm used to sticking the const keyword into function
After googling, I have only found only this sad forum question . Is it
Having been googling for hours, I realize that users can use either xml file(orm.xml,

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.