Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

void keyword

7 views
Skip to first unread message

Scott

unread,
Oct 29, 2004, 3:00:05 PM10/29/04
to
Can anyone please give me a broef explanation of what the void keyword is
for? What does it do? Do I need to use it?

Thanks,
Scott

Mattias Sjögren

unread,
Oct 29, 2004, 3:10:32 PM10/29/04
to

>Can anyone please give me a broef explanation of what the void keyword is
>for? What does it do? Do I need to use it?

The most common use is to have it as the return type of methods that
don't return a value.

void Foo()
{
// don't return anything
}

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Ansil MCAD

unread,
Oct 29, 2004, 11:48:06 PM10/29/04
to
hi
When used as the return type for a method, void specifies that the method
does not return a value.
void is not allowed in a method's parameter list. A method that takes no
parameters and returns no value is declared as follows:

void MyMethod();
{

}
regards
Ansil
anz...@gmail.com

Bob Grommes

unread,
Oct 30, 2004, 10:34:40 PM10/30/04
to
Many languages have a separate syntax for methods that return a value vs
those that don't. VB and VB.NET hav Sub vs Function, FoxPro has Procedure
vs Function, etc. C# just has a function syntax with a faux return type,
void, to indicate that nothing is to be returned. This is characteristic of
all C-family languages including Java and C++.

--Bob

"Scott" <Sc...@discussions.microsoft.com> wrote in message
news:11D5F97B-6BEE-4DB9...@microsoft.com...

0 new messages