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

What is serialization in .net?

566


Is array passed by reference in c#?

517


Can a constructor have a return type?

501


What is the property of class?

585


Write a program in C# for checking a given number is PRIME or not.

637






What is c# and why it is used for?

501


What is a ienumerator?

501


Which program construct must return a value?

568


What is the difference between mobile application and desktop application?

454


What is the default value of decimal in c#?

497


what is difference between is and as operators in c#?

539


What is xaml file in c#?

535


What is difference between an Structure and Class?

569


what is .NET framework architecture ??

1565


What is difference between comparable and comparator?

466