Hey guys, I was wondering if anyone can tell me if VOID in C# is a keyword? If so is it built in or library type? I cant seem to find decent information on this. Also I was wondering about ArrayList, which kind of type this is?

Any advice on this would be appreciated, many thanks!

Recommended Answers

All 4 Replies

void means a function (either) does not return a result or take parameters
...depending on where it's placed

//Takes a string; returns nothing
public static void DoSomething(string strData)
{
//...code goes here
   return; //optional
}

//returns a string; takes no parameters
public static string DoSomething(/*implied void*/)
{
//...code goes here
   return "some string"; //mandatory
}

In languages like Pascal and Visual Basic, functions that do not return values even have different names (other than function).
Pascal = Procedure
VB = Sub

If you are more used to Pascal type programing languages you could speak of procedures or subroutines. Meaning functionality done without returning a value. A function normally always returns a value. So in C-like languages void is used to handle this.

ArrayList is a list of any object you like.
This can be handy in certain circonstances, but it is not type save.
Better is to use the List<T> type.

Thanks for your help and advice on this guys, it is appreciated. I think I know how to proceed now!

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.