Connecting Tech Pros Worldwide Forums | Help | Site Map

void keyword

Scott
Guest
 
Posts: n/a
#1: Nov 16 '05
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
Guest
 
Posts: n/a
#2: Nov 16 '05

re: void keyword


[color=blue]
>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?[/color]

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
Guest
 
Posts: n/a
#3: Nov 16 '05

re: void keyword


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
anzboy@gmail.com

"Scott" wrote:
[color=blue]
> 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[/color]
Bob Grommes
Guest
 
Posts: n/a
#4: Nov 16 '05

re: void keyword


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" <Scott@discussions.microsoft.com> wrote in message
news:11D5F97B-6BEE-4DB9-98D5-50E2FD7B034B@microsoft.com...[color=blue]
> 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[/color]


Closed Thread


Similar C# / C Sharp bytes