Default value to a optional class variable parameter function call in vb.net -


i trying pass class variable optional parameter function. requires default value. set default value optional class variable.

private function savefruit(optional byval tempbanana bananaclass = ?) 

reference types' default value nothing (the null reference).

private function savefruit(optional byval tempbanana bananaclass = nothing)     if tempbanana nothing tempbanana = otherdefaultbanana     ..... end function 

as shown in example above have check if it's nothing is-operator before can use it, otherwise nullreferenceexception. can either assign instance exists or 1 initialize now.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -