Hi friends
What is a void return type?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Shivanand ArurPosted Nov 27, 2012, 7:28 AM
1. Any data type from C#
2. Object/Collections/.... It can simply be anything.
3. Void - This is used if you feel that your program does not require to return anything, then in that case "void" is used....
Here's a small example :
using System
public class Mathematics
{
public static void Main(String[] args)
{
int value = Add(); // Integer value is returned by this method.
Console.WriteLine(value);
Multiply();
}
public int Add() // Returns an Integer
{
int x = 5 + 5;
return x;
}
public void Multiply() // Returns nothing
{
int y = 5 * 5;
Console.WriteLine(y);
}
}
So the Add method returns an integer where as the Multiply method returns nothing. In short my point here is that returning any value depends upon the logic of your program and the requirement.
Hope this helps u out.
And Please mark any of these answers as ACCEPTED if it helped you!!!
Always follow this rule of marking an answer as accepted or correct if it satisfies your need. This will help u and also others to get proper/correct answer.
Thank you,
Shivanand Arur.
Shankar MPosted Nov 27, 2012, 6:30 AM
Hi Rahul,
When void is used in method, it Specifies that the method that does not return a value.
Thanks,
Shankar
Blocked AccountPosted Nov 27, 2012, 6:01 AM
When used void as the return type for a method, void specifies that the method does not return a value.