0

What is the Difference between Null and Void ?

Give the proper explanation

13th Sep 2019, 8:20 AM
Nachiket Gohil
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.
13th Sep 2019, 11:47 AM
Sonic
Sonic - avatar
+ 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
13th Sep 2019, 8:42 AM
Talha Altınel (The Last Sith Lord)
Talha Altınel (The Last Sith Lord) - avatar
+ 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.
13th Sep 2019, 9:49 AM
kc101010