Hi Venkat, Why you define Out parameter like this because Ref also can do the same(return multiple values to you)? I mean Ref also full fill the same..
class Program { static void Main(string[] args) { double areas = 0;
double cir = 0; Program.calculate(5, out areas, out cir); Console.WriteLine("the area is {0}", areas); Console.WriteLine("the circumfrence is {1}",cir); } public static void calculate(double radious, out double area,out double circum) { area = Math.PI * Math.Pow(radious, 2); circum = 2 * Math.PI * radious; }
using System; namespace helloWorldApplication { class Program { static void Main(string[] args) { double areas = 0;
double cir = 0; Program.calculate(5, out areas, out cir); Console.WriteLine("the area is {0}", areas); Console.WriteLine("the circumfrence is {0}", cir); Console.ReadKey(); } public static void calculate(double radious, out double area, out double circum) { area = Math.PI * Math.Pow(radious, 2); circum = 2 * Math.PI * radious; } } }
Hi Venkat,
ReplyDeleteWhy you define Out parameter like this because Ref also can do the same(return multiple values to you)?
I mean Ref also full fill the same..
-Sanjay
We need to initialize the variable used in case of Ref but this does not apply for OUT
ReplyDeleteusing System;
ReplyDeleteclass Program
{
public static void main()
{
int i = 0;
simplemethod(i);
Console.WriteLine(i);
Console.ReadKey();
}
public static void simplemethod(int j)
{
j=101;
}
}
the above program ives me error as program does not contains static main method..........plz help
Yes, you do not have a "Main" method. Just casing issue.
DeleteWrite main as Main ..Your problem will be solved.
DeleteIts too late
DeleteYou have pass the parameter in main method
The name of the method should be "Main"
Deleteit shouldn't be main.............
check it will work
Love you Venkat, You're the best
ReplyDeletesir how change order of output parameter in time of calling as like mssql
ReplyDeletewhy to use params keyword can't we directly pass an array as parameters?
ReplyDeleteclass Program
ReplyDelete{
static void Main(string[] args)
{
double areas = 0;
double cir = 0;
Program.calculate(5, out areas, out cir);
Console.WriteLine("the area is {0}", areas);
Console.WriteLine("the circumfrence is {1}",cir);
}
public static void calculate(double radious, out double area,out double circum)
{
area = Math.PI * Math.Pow(radious, 2);
circum = 2 * Math.PI * radious;
}
using System;
Deletenamespace helloWorldApplication
{
class Program
{
static void Main(string[] args)
{
double areas = 0;
double cir = 0;
Program.calculate(5, out areas, out cir);
Console.WriteLine("the area is {0}", areas);
Console.WriteLine("the circumfrence is {0}", cir);
Console.ReadKey();
}
public static void calculate(double radious, out double area, out double circum)
{
area = Math.PI * Math.Pow(radious, 2);
circum = 2 * Math.PI * radious;
}
}
}
use this modified program to get efficient output
this program compile successfully but at the run time it shows the error with the circumfrence...please help me sir..for short it out
ReplyDelete