0% found this document useful (0 votes)
4 views

C# Notes

C# NOTES
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

C# Notes

C# NOTES
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

c#

NOTE
1. CLASSES - 1ST LETTER IS CAPITAL
2. METHODS - 1 ST LETTER IS CAPITAL
3. NAMESPACES - 1ST LETTER CAPITAL
4. KEYWORDS - SMALL LETTER

COMPILE
C.... PATH > CSC FILENAME.CS

RUN
C.... PATH > FILE NAME

VS HAS PROVIDED US SOME IMPORTANT features INSIDE THE SOFTWARE


SOLUTION EXPLORER- THIS WINDOW CONTAINS ALL CURRENT PROJECT FILES
SERVER EXPLORER - TO PERFORM DATA BASE OPERATION
TOOL BOX - ALL GRAHICAL CONTROLS

console class by using this class we can perform all input/output operation on the
console
this class provide us various methods to perform i/o operations
this class is present in system namespaces

write()
writeLine()
Read()
ReadLine()
ReadKey()
Clear()

MSIL CODE
CLR

IF Statement
when you want to execute some specific code then you can use if statement.
if condition is true then if block will be executed oterwise else block will be
executed.

ELSE IF (LOOP)
when you want to execute some specific code then you can use ELSE if statement
CONSIDRING 1 OF THEM CAN BE TRUE FOR SAID CASE.

NESTED IF
IF 'IF' STATEMENT IS DEFINED WITHIN IF STATEMENT
EXAMPLE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
int pin,bal=2000;
Console.WriteLine("Enter ATM PIN....");
pin=int.Parse(Console.ReadLine());

if (pin == 777)
{
Console.WriteLine("welcoem to sbi....");
Console.WriteLine("Enter 1 for deposit\nEnter 2 for withdrwal\
nEnter 3 for balance Enquiry");
int opt = int.Parse(Console.ReadLine());
if(opt==1)
{ //deposit code here..
Console.WriteLine("Enter amount for deposit...");
int amt = int.Parse(Console.ReadLine());
bal = bal + amt;

Console.WriteLine("Now Available balance is "+bal);


}
else if(opt==2)
{//withdrwal code here...
Console.WriteLine("Enter amount for withdrwal...");
int amt = int.Parse(Console.ReadLine());
if (bal > amt)
bal = bal - amt;
else
Console.WriteLine("Insuffienct balance...");

Console.WriteLine("Now Available balance is " + bal);

}
else if(opt==3)
{ //balance enquiry
Console.WriteLine("Now Available balance is " + bal);
}
else
{
Console.WriteLine("invalid choice.....");
}
}
else
Console.WriteLine("invalid pin...");
Console.ReadKey();
}}}

LOOPING CONCEPT IS USED TO EXECUTE BLOCK OF CODE OR SET OF STATEMENTS RAPIDLY


WHILE

FOR
DO WHILE
FOR EACH

FACTORIAL

INT T, I=1;
CONSOLE.WRITELINE(ENTER A NO);
T=INT.PARSE(CONSOLE.READLINE());
WHILE(T>=1)
{
I=I*T;
T--
}
CONSOLE .WRITELINE("FACTORIAL="+I);

for loop

FOR(INITILIZATION, CONDITION, EVALUATION)


{
REPITION CODE
}

BREAK KEYWORD
TROWS THE PROGRA CONTROL OUT OF LOOP
CAN BE USED IN LOOP'S AND SWITCH

while loop
when we don't know the no. of iterations then we use while loop

do while

RANDOM NO
Random random = new Random();
int X = random.Next(0000,99999);///(MIN VALUE, MAX VALUE)

You might also like