using System;

public class Swapping
{
void Swap(ref int a, ref int b)
{
int temp;
temp=a;
a=b;
b=temp;

}

static void Main(string [] arg)
{
Swapping obj=new Swapping();
int n1,n2;
Console.WriteLine("Enter the no's:\t");
n1=Convert.ToInt32(Console.ReadLine());
n2=Convert.ToInt32(Console.ReadLine());
obj.Swap(ref n1, ref n2);

Console.WriteLine("The values of the numbers before swapping is :\t"+n1);
Console.WriteLine("The values of the numbers before swapping is :\t"+n2);
Console.ReadLine();
}
}

As we know parameters allow information to be passed in and out of a method.
When you define method, you can include list of parameters in parentheses.

Declaring Methods with parameters

Each parameter has a type and a name. u can declare parameters by placing parameter declaration inside parentheses. A syntax that is used to declare parameters is similar to the syntax that is used to declare local variables.

The syntax for declaring parameters inside methods

void Method(int n, string y)
{
// body.
}


the preceding code declares the method (Method) with out parameters and y. The first parameter is of type int and 2nd of type string.

Calling methods with Parameters

value type:

values r some time passed in parameters, therefore, the data can be transferred into the method but cannot be transferred out.

Reference type:

These r some times called In/Out parameters, therfore, the data can be transferred into the method and out again.

Pass Parameter by value


The simplest definition of a value parameter is the data type name followed by a variable name.
When a method is called, a new storage location is created for each value parameter. The values of the corresponding expressions are copied into them. The expressions supplied for each value parameter must be similar to the declaration of the value parameter or it must be a type that cane be implicitly converted to the value type .

example :
class calculator
{
void Addone(int var)
{
var++;
}
public static void Main(string [] arg)
{
Calculator Cal=new Calculator();
int number=6;
cal.Addone(number);
Console.WriteLine(number); //.................. Display value 6 .
}
}
pass parameter by reference

A reference parameter is a reference to a memory location of a data member.
Unlike a value parameter, a reference parameter does not create a new storage location., instead reference parameters represents the same location in memory as the variable that is supplied in the method call.

you can declare reference parameter by using the ref keyword before the data type, as shown in the following example:

class Calculator
{
void Addone(ref int var)
{
var++;
}
public static void Main(string [] arg)
{
Calculator obj=new Calculator();
int number =6;
obj.Addone(ref number);
Console.WriteLine(number);//....................Displays value 7.
}
}


Now a days kids like ..........undergo stress and tension right from a young age , thanks to fierce competition.The rat race starts from school Every one aims for the first rank.In this process, student get terribly stressed out . The most efficient way to ease out the tension is meditation .When xams are around the corner, take fifteen minute break every two hours while studying to do deep breathing exercises.One can also try visualization where you picture ur self in a pleasant place and breath slowly. Playing instrumental music also elps in de stressing. Having a bath in warm water relxes the muscles and soothes the mind .Exercising for atleast 20 minutes a day is also a must for de-stressing. Here are a few study tips that worked for...:

1. Get organized. Use a daily planner for study schedules.

2.keep your study area organized, tidy and clutter free,it helps you think better.

3. look over ur notes after classs to see if you have any questions and to mark important parts.

this working style has helped me a lot at time of exams.

Newer Posts Older Posts Home