Wriju's BLOG

.NET, Cloud and everything

VB.NET 10 : Optional Nullable Parameter

If you want to assign Nothing to the optional parameter in VB.NET 10, it is just like to obvious now,


Sub Main()


    ‘Passing value for the optional parament _age


    MyFunc(“Wriju”, “wriju@contoso.com”, 30)


 


    ‘No value is supplied for the optional parament _age


    MyFunc(“Writam”, “writam@contoso.com”)


End Sub


 


 


Sub MyFunc(ByVal _name As String,


           ByVal _email As String,


           Optional ByVal _age As Integer? = Nothing)


 


    Console.WriteLine(“Name={0}, Email={1}, Age={2}”,


                      _name, _email, _age.ToString())


End Sub


 


Namoskar!!!