Search........

Google

Thursday, March 6, 2008


/* Here we are going to add two numbers */
using System;


namespace nm1


{


class cl1


{


static void Main()


{


int inum1,inum2,add;


Console.WriteLine("enter a no");


inum1=Convert.ToInt32(Console.ReadLine());


Console.WriteLine("enter a second no.");


inum2=Convert.ToInt32(Console.ReadLine());


add=inum1+inum2;


Console.WriteLine("Result ="+add.ToString());


}


}


}

convert To Int

Lets try converting the program from string to int,float ,double,char

To interger "Convert.ToInt32(inputed value)";

To float we use "float.Parse(inputed value)",

To double "Convert.ToDouble(inputed value)",

To Character "Convert.ToChar(inputed value)"

using System;

namespace name1

{

class cls1

{

static void Main()

{

String str;

int inum;

Console.WriteLine(" Enter a number");

str=Console.ReadLine();

inum=Convert.ToInt32(str); // Here we are converting

Console.WriteLine("The numbe entred is "+inum);

}

}

}

Wednesday, March 5, 2008

Input

In this program we are discussing how to give an input . For getting the input we are using the command "Console.ReadLine()".The input we got will be in string format......


using System;
namespace inputdemo
{
class cls1
{
static void Main()
{
String str;
Console.WriteLine(" Enter Your Name");
str=Console.ReadLine();
Console.WriteLine("The Name Entered is "+str);

}
}
}




Sunday, March 2, 2008

How we will get the input....

using System;
namespace name
{
class Hello
{
static void Main()
{
String str;
Console.WriteLine(" Enter Your Name");
str=Console.ReadLine(); //here we will get the input , it is in string type
Console.WriteLine("Your Name is "+str);
}
}
}


Hello World......

N.B : While doing the console you should be vigilent about the case...Because c# is case sensitive

using System;
namespace Hello
{
class world
{
static void Main()
{
Console.WriteLine("Hello World");
}
}
}

This is how console Application works,,,,

Console

Here it is explained how to use the console application


Note:-
Save the progarm with the extension .cs (if it is csharp)
eg:-program.cs

To compile the program go to the visual studio and take the visual studio command promt......
Change the control from the present folder to the folder where your program is stored

Suppose ur program is at D:\paul\vcs\program.cs

now to change your contorl use
c:\visuall\v8>d: <-(enter)
d:\>cd paul <-
d:\paul>cd vcs <-
D:\paul\vcs>csc progarm.cs


To run

D:\paul\vcs>program.exe <-