Saturday, March 01, 2008

C# - Types of function and Enumeration

It allows you to create your own data types.You can't declare the enum in the main block because it cant execute,its only a definition so youmust place it out of main.each value in enumeration can accept a storage type which is int by default.
enum days
using the enum value in main method.
days d;
Response.Write(d); // friday
Function call by Ref:
Compiler doesnt want to create temprory variable for the parameters of the function.So less overhead and tremendous functionality available while using this function.It uses the same value in the calling function.
out parameter function.
An function can return only one value at the time of execution.If you require more than on value return by the function,you can pass the out parameter to your function.out varialble must be unassigned declared.

public int MuruOutParameter(out int x)
int y=5;
int x=6;
Call the function in the main
int p;
Console.WriteLine(MuruOutParameter(out p)
output : 6