Click here to Skip to main content
15,881,832 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
is void a datatype ?
describe whether void is return type or datatype ?
if return type than what it returns ??
Posted
Comments
Sergey Alexandrovich Kryukov 10-Jan-13 13:07pm    
Do you think that asking is easier then just reading? :-)
—SA

Void is a keyword in c# that indicates the function doesn't return a value.
Void does not exist in VB.NET
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Jan-13 13:06pm    
Not true, period. Voted 1, sorry.
This is incomplete and not quite accurate explanation, but, unfortunately, I also misread you, so I changed my vote.
Please see more correct Solution 1.

Here is what happens with VB.NET: the types are of course exactly the same. As "void" is not a type in any sense of this word, but only a syntax artifact (and, by the way, pretty weird, inherited from the lame C), "void" is really not needed. "SomeFunction(void)" is a total bogus, should be "SomeFunction(void)", "void F()" simply means that the return is not used (not return type, but return itself, which is important), and "void* pointer" is not needed in VB, because there are no traditional pointers at all (in "unsafe"), IntPtr can be used.

Overall, as void never means any something really existing, such notion is not needed, in general case.

Well, there is also System.Void, but this is only needed as a result of Reflection, to denote return of "Sub".

—SA
Adam R Harris 10-Jan-13 15:06pm    
Huh, I didn't know VB used void at all. I tried working the googles but i couldnt find anything related to VB.NET and void. Do you know of anywhere i can read up on it? not trying to be a jerk or discount your comment I am genuinely curious.
Sergey Alexandrovich Kryukov 10-Jan-13 16:30pm    
Oh! Sorry, I made some mistake, trying to fix it.

Thank you for this comment — this way, you helped me to fix my mistake. I just misread you, as if you were talking about .NET in general. I've done the same mistake in my comment to Solution 1. I tried to explain everything above.

That's why it's a right idea to try to discuss everything if there is a concern, and motivate the votes. Only this way we get a chance to fix out mistakes.
You did it, thank you.

—SA
Basically it means "nothing" or "no type".
There are 3 basic ways that void is used:

1) Function argument: int myFunc(void) -- the function takes nothing.
2) Function return value: void myFunc(int) -- the function returns nothing
3) Generic data pointer: void* data; -- 'data' is a pointer to data of unknown type, and cannot be dereferenced
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Jan-13 13:06pm    
Explained. My 5.
Wait a second... you did not address VB.NET as OP wanted. Whatever...
—SA
ridoy 10-Jan-13 13:14pm    
Thanks SA,yes i miss that but i don't edit those,because OP will know all those void types which is used most of the programming language..:)
Sergey Alexandrovich Kryukov 10-Jan-13 16:14pm    
Fair enough.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900