void keyword

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
(e-mail address removed)
 
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
 
Back
Top