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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:23:32+00:00 2026-05-28T04:23:32+00:00

I have a query about type of null. I have a small program can

  • 0

I have a query about type of null.
I have a small program can anyone tell me about this.

public class TestApplication
{
    public void ShowText(object  ob)
    {
        Console.Write("Inside object");
    }
    public void ShowText(string str)
    {
        Console.Write("Inside string");
    }
    public void ShowText(int i)
    {
        Console.Write("Inside int.");
    }
    public void ShowText(char c)
    {
        Console.Write("Inside Character");
    }
    static void Main(string[] args)
    {
        new TestApplication().ShowText(null);            
        Console.Read();
    }
}

Why it call the string function.
Is it means the type of null is string.
It might look a foolish conclusion but I am not able to find the region why it is calling the function of string.

  • 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-28T04:23:32+00:00Added an answer on May 28, 2026 at 4:23 am

    Your question about the type of the null literal is answered here: What is the type of null literal?

    But that doesn’t really matter when talking about overload resolution. The actual null value itself will automatically be converted to whatever type it ends up as.

    As for why the string overload is called:

    1. You can’t pass null as int and char parameters as they’re value types, so those two overloads are out. (They could have been candidates had you made them nullable int? and char? types, but I won’t go into that.)

    2. Between the two other overloads taking reference types, string is a more specific type than object. That is, it derives from (and is therefore implicitly convertible to) object. Further, from the following section in the C# language spec (emphasis mine):

      7.5.3.5 Better conversion target

      Given two different types T1 and T2, T1 is a better conversion target than T2 if at least one of the following holds:

      • An implicit conversion from T1 to T2 exists, and no implicit conversion from T2 to T1 exists

      • …

    Thus, the string overload is chosen as the best fit.

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

Sidebar

Related Questions

HI, I have this query about smart pointers. I heard from one of my
I have a query that looks like this: public IList<Post> FetchLatestOrders(int pageIndex, int recordCount)
I have a question about LINQ query. Normally a query returns a IEnumerable<T> type.
I have this table: create table demo ( key number(10) not null, type varchar2(3)
i have a general question about how sql server evaluates the joins.The query is
I have a query that originally looks like this: select c.Id, c.Name, c.CountryCode, c.CustomerNumber,
I have this query in sql server 2000: select pwdencrypt('AAAA') which outputs an encrypted
So I have written a query that will grab an order (this is for
I have a question about a particular query I'd like to execute against a
I have a question about, how to analyze a query to know performance of

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.