0
What is the Difference between Null and Void ?
Give the proper explanation
3 odpowiedzi
+ 4
Void is used to indicate that a function/method does not return any data type. Null indicates that a pointer variable is not pointing to any address.
+ 2
Null means nothing for data types. Void means function returned type have to be nothing. you also can not return null from a void function
+ 2
You usually use void when a method does not return a variable. When you have to return a variable you specify the var type with a keyword which replaces 'void'.
Example:
Public static int(){}
- The above would have to return an int.
You can use this for all variables as far as I know.
As mentioned above, null sets any variable to just nothing. It doesn't mean its assigned zero. It removes the assignment altogether.