C# Statements
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
namespace CSharp_Shell
{
/*
public enum colors
{
red,
yellow,
green
}
*/
/*
struct employee
{
public string name;
public int salary;
public int age;
}
*/
public class Program
{
public static void Main()
{
/*
//Give percentage of a number
int input, percentage, option;
float result;
start:
Console.Write("Enter Number : ");
input = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter Percentage : ");
percentage = Convert.ToInt32(Console.ReadLine());
//
result = (float)input * percentage / 100;
//
Console.WriteLine("{0}% of {1} is {2}", percentage, input, result);
Console.Write("Enter 1 to continue and 0 to exit : ");
option = Convert.ToInt32(Console.ReadLine());
if (option == 1)
{
Console.Clear();
goto start;
}
*/
//
/*
//Checked and unchecked
int num;
num = int.MaxValue;
//
checked // this will throw an exception
{
num = num + 2;
}
unchecked // This will ignore the exception
{
num = num + 2;
}
//
Console.WriteLine(num);
*/
/*
//Return Statement
int num1, num2, sum;
//
sum = Add(5, 2);
Console.WriteLine("Sum = {0}", sum);
*/
/*
//Break and Continue
int count = 0;
//
while (count < 20)
{
count++;
if (count <= 5)
continue;
else if(count== 10)
break;
else
Console.WriteLine(count);
}
*/
//
/*
//Enumeration
int x = (int)colors.red;
int y = (int)colors.yellow;
int z = (int)colors.green;
Console.WriteLine("Red position {0}\nYellow position {1}\nGreen position {2}", x, y, z);
*/
//
/*
//Struct data type
employee employee1;
//
employee1.name = "sam";
employee1.salary = 28133;
employee1.age = 25;
//
Console.WriteLine(employee1.name);
Console.WriteLine(employee1.age);
Console.WriteLine(employee1.salary);
*/
}
//
//
//
//
//Methods
#region
//
public static int Add(int num1, int num2)
{
int sum;
sum = num1 + num2;
return sum;
}
#endregion
}
}
Comments
Post a Comment