Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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?

Answers were Sorted based on User's Feedback



i have a question which is quite simple but yet complicated for me my question is why do we use ..

Answer / sathish

Just to add on that,
i guess, Compiler basically looks the pre-defined syntax or
format rather than just the keyword, like say, it parses
function as ACCESS MODIFIER RETURNTYPE FUNCTION() e.g.
public void test(). Here ACCESS MODIFIER is optional,
becuase bydefault it is PRIVATE, but return type is
mandatory, that is why, eventhough you don't return any
value, it is mandatory to instruct compilter that, the
function does not return anything.

Is This Answer Correct ?    4 Yes 0 No

i have a question which is quite simple but yet complicated for me my question is why do we use ..

Answer / 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

More C Sharp Interview Questions

If you define a user defined data type by using the class keyword, is it a value type or reference type?

0 Answers  


What is a delegate, why should you use it and how do you call it ?

1 Answers  


What is the difference between CONST and READONLY?

0 Answers   BirlaSoft,


What are the keywords used to pass parameters to the base class and how do I invoke other constructors.

3 Answers  


Why do we need events in c#?

0 Answers  


What Is A Satellite Assembly?

0 Answers   PUCIT, Siebel Systems,


What is difference between array and list?

0 Answers  


What is meant by generics in c#?

0 Answers  


What is the difference between Java and .NET garbage collectors?

0 Answers   BirlaSoft,


Can we inherit class that contains only one private constructor?

0 Answers  


Explain About Assembly in .NET, types of assemblies, their difference, How to register into GAC. How to generate the strong names & its use.

0 Answers  


To whom a method is accesssed if it is marked as protected internal ?

0 Answers   Siebel,


Categories