2
Answers

NP134 null

Maha

Maha

16y
1.9k
1

Hi Guys

 

NP134 null

 

In the following program string value is declared as a null. Is there any advantage of declaring string value as a null? Because string is a reference-type variable whereas null is a default value of reference-type variables.      

 

Please explain.

 

Thank you

 

using System;

 

class MainClass

{

    public static void Main(string[] args)

    {

        string formStr = null;

 

        formStr = string.Format("you had {0:C} in your account?", 99989.987);

 

        Console.WriteLine(formStr);

    }

}

/*

you had $99,989.99 in your account?

*/

Answers (2)