Parameter of oops
Parameter is used to make the dynamic methods ..
Parameter is 2 types ..
Input parameter :
In input parameter is used to bringing the value In to the methods for execution are called as a input parameter .
Output Parameter :
In output parameter is used for carrying the value out of the method for execution are called as a output parameter ..
We can send a value out of a methods in two ways :
A simple program using return statement :
using System ; class Main { public static void Main () { int SomeInt=8; int s =Sum(7,SomeInt); Console.WriteLine(s); Console.ReadLine(); } public static int Sum (int x,int y ) { return x+y; } }
Program for output Parameter :
using System ; class outparam { public void math (int a , int b , ref int c ,ref int d) { c=a+b; d=a*b; } public void math2(int a ,int b ,out in c ,out int d ) { c=a-b; d=a*b; } public void AddNums (int x ,int y=40 , int z=150) { Console.WriteLine(x+y+z); } static void Main() { Outparam op =new outparam(); op.AddNums(100); op.AddNums(100,100); op.AddNums(100 ,z ,100); op.AddNums(100 ,100 ,100); int x =0 ,y=0; op.math1(100,40,ref x ,ref y); Console.WriteLine(x + “ “ +y); int m,n; op.math2(100,30,out m, out n); Console.WriteLine(m + “ “ +n); Console.ReadLine(); } }