Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
is void a datatype ?
describe whether void is return type or datatype ?
if return type than what it returns ??
Posted 10-Jan-13 7:41am
Comments
Sergey Alexandrovich Kryukov at 10-Jan-13 13:07pm
   
Do you think that asking is easier then just reading? :-)
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 10-Jan-13 13:06pm
   
Explained. My 5.
Wait a second... you did not address VB.NET as OP wanted. Whatever...
—SA
ridoy at 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 at 10-Jan-13 16:14pm
   
Fair enough.
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Void is a keyword in c# that indicates the function doesn't return a value.
Void does not exist in VB.NET
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 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 at 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 at 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

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

  Print Answers RSS
0 Kornfeld Eliyahu Peter 275
1 Maciej Los 214
2 Sergey Alexandrovich Kryukov 200
3 King Fisher 185
4 OriginalGriff 163
0 OriginalGriff 6,223
1 DamithSL 4,724
2 Maciej Los 4,196
3 Kornfeld Eliyahu Peter 3,894
4 Sergey Alexandrovich Kryukov 3,496


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 10 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100