IN THIS POST WE WILL LEARN 1. NULLABLE TYPE IN C# 2. NULL COALESCING OPERATOR ?? Type in C# In C# types are divided into 2 broad Categories Reference Types : Interface , Class , Delegates , Arrays E.t.c Value Types : Int , Float , Double , Structs ,Enums E.t.c By Default value types are non nullable. To make then nullable Use ? int r= 0 (r is non nullable, so r cannot be set null , r= null will generate Error ) int? m =0 (m is nullable int , so m=null is legal) Example : Nullable Type In C# using System; namespace NullableTypeInCshape { class Program { static void Main(string[] args) { bool? AreYouvirgin = true; if (AreYouvirgin ==true) ...
Comments
Post a Comment