i have a question which is quite simple but yet complicated
for me
my question is why do we use void, if it does not return
anything to the compiler?
if it is used for normal display it can also be done by
what is called Console.Write() or Consol.WriteLine() and if
i do not use void with my method then my compiler throws me
an error. if i return a value say integer then i write
public int fun() display of the result can also be done
here
then why is it so necessary to use void with a function and
why so compiler throw us an error if v don't use void
return type?

Answer Posted / n r s reddy

Hi buddy...

its as simple as your questino.

By using key word VOID, just its an informationto the
comiler stating that following code is not goig to return
anything. Where we can save some resources like memory
etc... from functionality point of view.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

I have 3 overloaded constructors in my class. In order to avoid making instance of the class do I need to make all constructors to private?

549


What are PE(Portable Executable)?

538


Define delegation in .net?

488


What is the name of c# compiler?

630


How do you implement thread synchronization (object.wait, notify,and criticalsection) in c#?

619






What is typeof c#?

518


What is string method in c#?

495


Name some properties of array.

479


What is difference between interface and abstraction?

459


What is ControlBox Propertie

571


What is master page in asp net c#?

472


Explain About sn.exe

500


What is default access modifier for class in c#?

495


What floating point types is supported in C#?

589


Differentiate between copy and default constructor.

568