C#.. visual studio
2.6K subscribers
2 links
Download Telegram
Hello word program in console application

console. WriteLine("hello world");


Or

System.console. writeLine("hello world");
Explain the control statements in c# with suitable example.
Forwarded from Deleted Account
Control statements in c#

Means branching and looping


Branching includes

If -else
Switch-case
......

Looping includes

For
While
Do while
For each
Forwarded from Deleted Account
If(a>0)
{
console. WriteLine("positive num");
}
else
{
console. WriteLine("negative num");
}

console. ReadKey();
Forwarded from Deleted Account
Int d=2;
Switch(d)
{
Case 1:

console. WriteLine("sunday");
break;

Case 2:

console. WriteLine("monday");
break;

Case 3:

console. WriteLine("tuesday");
break;

Default:

console. WriteLine("not a day");



}
Loops
Forwarded from Deleted Account
int i;
for(i=1;i<=10;i++)
{
console. WriteLine(i);

}
Forwarded from Deleted Account
Int i=1;
While (i<=10)
{
console. WriteLine(i);
i++;
}
Forwarded from Deleted Account
Int i=1;
do
{
console. WriteLine(i);
i++;
}
while (i<=10)
Loop output is same
12345678910
Forwarded from Bsc computor scienc (science Ks)
C# Program to Swap two Numbers

using System;


namespace Program
{
class Program
{
static void Main (string [ ] args)
{
int num1, num2, temp ;

Console . WriteLine (" Enter the First Number : " ) ;


num1 = int .Parse
( Console. ReadLine( )) ;


Console . WriteLine (" Enter the Second Number : " ) ;
num2 = int .Parse
( Console. ReadLine( )) ;
temp = num1 ;
num1 = num2 ;
num2 = temp ;

Console . WriteLine (" After Swapping : " );

Console . WriteLine ("\n First Number : " + num1 );

Console . WriteLine("
Second Number : " + num2 );



Console . ReadLine () ;
}
}
}
Forwarded from Bsc computor scienc (science Ks)
Here is the output of the C# Program:
Enter the First Number : 23
Enter the Second Number : 25
After Swapping :
First Number : 25
Second Number : 23
Forwarded from Deleted Account
static void SwapByRef(ref int x, ref int y)
{
int temp = x;
x = y;
y = temp;
}
When you call the SwapByRef method, use the ref keyword in the call, as shown in the following example.
C#
static void Main()
{
int i = 2, j = 3;
System.Console.WriteLine("i = {0} j = {1}" , i, j);

SwapByRef (ref i, ref j);

System.Console.WriteLine("i = {0} j = {1}" , i, j);

// Keep the console window open in debug mode.
System.Console.WriteLine("Press any key to exit.");
System.Console.ReadKey();
}
/* Output:
i = 2 j = 3
i = 3 j = 2
*/