mercredi 5 juillet 2017

C# booleans != null Meaning

string Shipment = null;


public bool IsShipped

{

get {return Shipment != null;} 



}

if(IsShipped)
{
   throw new InvalidOperationException("Am i null ?")
}

String Shipment = "Something";

Console.Writeline("Is it still null?");

first off what will be the output, please explain.Thanks a heap.

how is the IsShipped method converting/reading the value of Shipment as True/False???

is it because at runtime... the public bool IsShipped method is automatic false or public bool IsShipped is taking the property below

get { Shipment != null;}

and verifying if its true/false by comparing it to

string Shipment = null;

which, if i am not mistaken.... public bool IsShipped now carries a value of Falsy

Aucun commentaire:

Enregistrer un commentaire