C# Program to Swap Two Numbers Using Classes and Objects

Below Program uses Classes and objects feature of c# to swap two numbers..

Program is running successfully in Visual Basic 2008…
Here is the program…

System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication10 {
class swap {
int num1,num2,temp; public void swapped() {
Console.WriteLine(“Enter the no. “); num1= Convert.ToInt32(Console.ReadLine()); num2=Convert.ToInt32(Console.ReadLine()); temp=num1;
Console.WriteLine(“Swap no. is “ + num1); Console.WriteLine(“Swap no. is “ + num2); }
public class main {
static void Main(string[] args) {
swap display = new swap(); display.swapped();
Console.ReadLine(); }

Simply Copy paste in the visual basic Window to run the program or copy down in a notepad file and run using cmd commands if you know.

Add Comment