Está en la página 1de 75

Write a simple program in which calculate the total amount of items that are sold.

Calculate Total Price after discount.

Program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ItemCalc
{
class Program
{
static void Main(string[] args)
{

int[] ItemNUM = new int[5];


string[] ITEMName = new string[5];
double[] unitprice = new double[5];
int[] quantiy = new int[5];
double[] price= new double[5];
double discount;
double[] Total = new double[5];
double Sum=0;

for (int i = 0; i < 5; i++)


{
ItemNUM[i] = i + 1;
Console.WriteLine("IITEM {0}",ItemNUM[i]);
Console.WriteLine("Enter ITEM Name");
ITEMName[i] = Console.ReadLine();
Console.WriteLine("Enter unit price");
unitprice[i] = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter Quantity");
quantiy[i] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
Total[i] = quantiy[i] * unitprice[i];
Console.WriteLine("Total Price of ITEM:{0} ={1}\n",ItemNUM[i],Total[i]);
Sum = Sum + Total[i];

}
Console.WriteLine("ENter Discount in %");
int disc =Convert.ToInt32( Console.ReadLine());

Console.WriteLine("\nITEM \t ITEM Name\t Unit Price \t Quantity\t Total Price\n");

for(int i=0; i<5;i++)


{
Console.WriteLine("ITEM:{0} \t{1}\t\t{2}\t\t{3}\t\t{4}", ItemNUM[i], ITEMName[i],
unitprice[i], quantiy[i], Total[i]);
}
Console.WriteLine("\nTotal Amount={0}",Sum);
discount = Convert.ToDouble((disc / 100.0) * Sum);
double TotalPrice = Sum - discount;
Console.WriteLine("Amount After discount={0}",TotalPrice);
Console.WriteLine("Please recieve the amount....!!! ");
}
}

Output:
Student Class Code
Program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Student
{
class Student
{
string SName;
String FName;
String Class;
string Section;
int Regno;
String address;
string dob;
string age;
string email;

public void data()


{
Console.WriteLine("Enter Name: ");
SName = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("Enter Father's Name: ");
FName = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("Enter Class: ");
Class = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("Enter Class Section: ");
Section = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("Enter Registration number: ");
Regno =Convert.ToInt32 (Console.ReadLine());
Console.WriteLine("");
Console.WriteLine("Enter Complete Address: ");
address = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("Enter Date of Birth: ");
dob = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("Enter Age: ");
age = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("Enter E-mail Address: ");
email = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
}
public void Display()

Console.WriteLine("");
Console.WriteLine("Student's Name: {0}", SName);
Console.WriteLine("");
Console.WriteLine("Son/Daughter Of: {0}", FName);
Console.WriteLine("");
Console.WriteLine(" Class: {0}", Class);
Console.WriteLine("");
Console.WriteLine(" Section: {0}", Section);
Console.WriteLine("");
Console.WriteLine(" Reg.No#: {0}", Regno);
Console.WriteLine("");
Console.WriteLine(" Address: {0}", address);
Console.WriteLine("");
Console.WriteLine(" Date of Birth: {0}", dob);
Console.WriteLine("");
Console.WriteLine(" Age: {0}", age);
Console.WriteLine("");
Console.WriteLine(" E-mail Id: {0}", email);
Console.WriteLine("");

}
class Student1
{

static void Main(string[] args)


{
Student S1 = new Student();
S1.data();
S1.Display();
}
}
}
}
Write a simple program in which calculate the total amount of items that are sold.
Calculate Total Price after discount.

Program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITEM_Calculation
{
class ITEM
{
int[] num = new int[5];
string[] PName = new string[5];
double[] unitprice = new double[5];
int[] quantiy = new int[5];
double[] TPrice = new double[5];
double discount;
double[] Total = new double[5];
double Sum = 0;

public void GetData()


{

for (int i = 0; i < 5; i++)


{

num[i] = i + 1;
Console.WriteLine("\nProduct:{0}", num[i]);

Console.WriteLine("Enter product name");


PName[i] = Console.ReadLine();
Console.WriteLine("Enter unit price");
unitprice[i] = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter Quantity");
quantiy[i] = Convert.ToInt32(Console.ReadLine());
TPrice[i] = quantiy[i] * unitprice[i];
Console.WriteLine("Total price of this product={0}",TPrice[i]);
Sum = Sum + TPrice[i];
}

}
public void Display()
{
Console.WriteLine("ENter Discount in %");
int disc = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("\nITEM \t ITEM Name\t Unit Price \t Quantity\t Total Price\n");


for (int i = 0; i < 5; i++)
{
Console.WriteLine("ITEM:
{0}\t{1}\t\t{2}\t\t{3}\t\t{4}",i+1,PName[i],unitprice[i],quantiy[i],TPrice[i]);
}
Console.WriteLine("\nTotal Amount={0}", Sum);
discount = Convert.ToDouble((disc / 100.0) * Sum);
double TotalPrice = Sum - discount;
Console.WriteLine("Amount After discount={0}", TotalPrice);
Console.WriteLine("Please recieve the amount....!!! ");
}
}
class Program
{
static void Main(string[] args)
{
ITEM I1 = new ITEM();
I1.GetData();
I1.Display();

}
}
}

Output:
Write a program in Wnindows Form Application. Generate electric bill, input User Name and pasword
12345, login and enter information required to generate bill.

Coding Form 1:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Suigas
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
if (textBox2.Text == "12345")
{
Form2 f2 = new Form2();
f2.Show();
Hide();
}

private void textBox1_TextChanged(object sender, EventArgs e)


{

private void Form1_Load(object sender, EventArgs e)


{

}
}
}
Coding Form 2:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Suigas
{
public partial class Form2 : Form
{
public static string name, type, address;
public static double cunit, punit, conUnit, prsUnit, ttlbill, mtrno, units;

public Form2()
{
InitializeComponent();
}

private void Form2_Load(object sender, EventArgs e)


{

private void button1_Click(object sender, EventArgs e)


{
name = textBox1.Text;
mtrno = (Convert.ToDouble(textBox2.Text));
address = textBox3.Text;
punit = (Convert.ToDouble(textBox4.Text));
cunit = (Convert.ToDouble(textBox5.Text));
type = textBox6.Text;
conUnit = punit - cunit;

if ((type == "commercial") || (type == "Commercial"))


{
prsUnit = 8.0;
conUnit = cunit - punit;
ttlbill = prsUnit * conUnit;
}
else
{
prsUnit = 4.0;
conUnit = cunit - punit;
ttlbill = prsUnit * conUnit;
}

Form3 f3 = new Form3();


f3.Show();
Hide();

private void textBox1_TextChanged(object sender, EventArgs e)


{
}
}
}

Coding Form 3:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Suigas
{
public partial class Form3 : Form
{
public static double m, pc, amt;
public static string t;
public static string nme, ad;

public Form3()
{
InitializeComponent();
}

private void Form3_Load(object sender, EventArgs e)


{

nme = Form2.name;
label1.Text = nme.ToString();

ad = Form2.address;
label2.Text = ad.ToString();

m = Form2.mtrno;
label3.Text = m.ToString ();

pc = Form2.conUnit;
label4.Text = pc.ToString();

t = Form2.type;
label5.Text = t.ToString();

amt = Form2.ttlbill;
label6.Text = amt.ToString();
}

private void label1_Click(object sender, EventArgs e)


{

private void label12_Click(object sender, EventArgs e)


{

}
}
}

Car Class Code


Program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CarClass
{

class Car
{

string Name;
string model;
string made;
string colour;
string EnginePower;
string AutoOrNon;

public void Data()


{
Console.WriteLine("Enter Name of Car");
Name = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("ENter model #");
model = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("made by");
made = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("Enter Colour");
colour = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("Power in cyclic cylender CC ");
EnginePower = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("Automatic or non-Automatic");
AutoOrNon = Console.ReadLine();
Console.WriteLine("");

public void Display()


{
Console.WriteLine(" Name: {0}", Name);
Console.WriteLine(" Model # is: {0}", model);
Console.WriteLine(" Company: {0}", made);
Console.WriteLine(" Colour: {0}", colour);
Console.WriteLine(" Automatic/Manual?: {0}", AutoOrNon);
Console.WriteLine("Engine power in Horse or CC: {0}", EnginePower);

}
}

class program1
{
static void Main(string[] args)
{
Car c1 = new Car();
c1.Data();
c1.Display();
}
}
}

Output:
Cell Class Code
Program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CellPhone
{
class cellphone
{
string Name;
string model;
string made;
string IMEI;
string camera;
int storage;
int extStorage;

public void Data()


{
Console.WriteLine("Enter Name of Cell phone: ");
Name = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("ENter model #: ");
model = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("made in: ");
made = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("Enter IMEI code: ");
IMEI = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("Camera or simple non-camera?: ");
camera = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("internal Storage capacity in Mb: ");
storage = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("");
Console.WriteLine("Enter external storage Gb: ");
extStorage = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("");

}
public void Display()
{
Console.WriteLine(" Name: {0}", Name);
Console.WriteLine("");
Console.WriteLine(" Model is: {0}", model);
Console.WriteLine("");
Console.WriteLine(" Made in: {0}", made);
Console.WriteLine("");
Console.WriteLine(" IMEI # is: {0}", IMEI);
Console.WriteLine("");
Console.WriteLine(" Megapixel:{0}", camera);
Console.WriteLine("");
Console.WriteLine(" Internal sorage: {0}", storage);
Console.WriteLine("");
Console.WriteLine("External storage: {0}", extStorage);
Console.WriteLine("");

}
}
class program1
{
static void Main(string[] args)
{
cellphone c1 = new cellphone();
c1.Data();
c1.Display();
}
}
}
Write a simple program in which calculate the total amount of items that are sold.
Calculate Total Price after discount.

Program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ItemCalc
{
class Program
{
static void Main(string[] args)
{

int[] ItemNUM = new int[5];


string[] ITEMName = new string[5];
double[] unitprice = new double[5];
int[] quantiy = new int[5];
double[] price= new double[5];
double discount;
double[] Total = new double[5];
double Sum=0;

for (int i = 0; i < 5; i++)


{
ItemNUM[i] = i + 1;
Console.WriteLine("IITEM {0}",ItemNUM[i]);
Console.WriteLine("Enter ITEM Name");
ITEMName[i] = Console.ReadLine();
Console.WriteLine("Enter unit price");
unitprice[i] = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter Quantity");
quantiy[i] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
Total[i] = quantiy[i] * unitprice[i];
Console.WriteLine("Total Price of ITEM:{0} ={1}\n",ItemNUM[i],Total[i]);
Sum = Sum + Total[i];

}
Console.WriteLine("ENter Discount in %");
int disc =Convert.ToInt32( Console.ReadLine());

Console.WriteLine("\nITEM \t ITEM Name\t Unit Price \t Quantity\t Total Price\n");

for(int i=0; i<5;i++)


{
Console.WriteLine("ITEM:{0} \t{1}\t\t{2}\t\t{3}\t\t{4}", ItemNUM[i], ITEMName[i],
unitprice[i], quantiy[i], Total[i]);
}
Console.WriteLine("\nTotal Amount={0}",Sum);
discount = Convert.ToDouble((disc / 100.0) * Sum);
double TotalPrice = Sum - discount;
Console.WriteLine("Amount After discount={0}",TotalPrice);
Console.WriteLine("Please recieve the amount....!!! ");
}
}

Output:
Write a program to add distance give in meter, kilometer, and centieter by
using operator overloading method.

Program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Distance
{
int kilometer;
int meter;
int centimeter;

public Distance(int km, int m, int cm)


{
kilometer = km;
meter = m;
centimeter = cm;
}
public void Display()
{
Console.WriteLine("The Total Distance is {0} kilometer, {1} meter ,{2} centimeter",
kilometer, meter, centimeter);
}
public static Distance operator +(Distance fd, Distance sd)
{
int km, m, cm;

km = fd.kilometer + sd.kilometer;
m = fd.meter + sd.meter;
cm = fd.centimeter + sd.centimeter;

if(m > 999)


{
for (int n = m; m > 999;m-=1000 )
{
km++;

if (cm > 99)


{
for (int a = cm; cm > 99; cm-=100 )
{
m++;
}
}
}
}

Distance d = new Distance(km, m, cm);


return d;
}

static void Main(string[] args)


{
Distance d1 = new Distance(18, 1000, 18020);
Distance d2 = new Distance(25, 2000, 250);
Distance d3 = d1 + d2;
d3.Display();
}
}
}

Output:

Make an exception in a program & handle it.


CODING:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace exceptionhandling
{
class arrayexception : Exception
{
public arrayexception() :
base("please enter the command line arguement")
{
}
}
class throwarrayexception
{
public throwarrayexception(int a)
{
try { checksize(a); }
catch (arrayexception ae)
{
Console.WriteLine(ae.Message);
}
}
public void checksize(int a)
{
if (a == 0)
throw new arrayexception();
else
{
Console.WriteLine("the size of arguements passed to main method is {0}", a);
}
}
class program
{
static void Main(string[] args)
{
new throwarrayexception(args.Length);
}
}
}
}

OUTPUT:

Design a web browser in C#


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BrowserExample
{
public partial class Form1 : Form
{
public Form1({
InitializeComponent();
}
private void txt_Url_KeyPress(object sender, KeyPressEventArgs e){
if (e.KeyChar == (char)13)
{
webBrowser1.Navigate(txt_Url.Text);
}
}
private void Form1_Load(object sender, EventArgs e){
btn_Stop.Enabled = false;
btn_fwd.Enabled = false;
btn_backwrd.Enabled = false;
}
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e){
txt_Url.Text = webBrowser1.Url.ToString();
this.Text = webBrowser1.DocumentTitle.ToString();
}
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
btn_Stop.Enabled = true;
}
private void webBrowser1_DocumentCompleted(object sender,WebBrowserDocume
ntCompletedEventArgs e){
btn_Stop.Enabled = false;
if (webBrowser1.CanGoBack){
btn_fwd.Enabled = true;}
else{
btn_fwd.Enabled = false;}
if (webBrowser1.CanGoBack){
btn_fwd.Enabled = true;}
else{
btn_fwd.Enabled = false;
}
}
private void btn_Home_Click_1(object sender, EventArgs e){
webBrowser1.GoHome();
webBrowser1.Text = webBrowser1.Url.ToString();
}
private void btn_backwrd_Click_1(object sender, EventArgs e){
webBrowser1.GoBack();
txt_Url.Text = webBrowser1.Url.ToString();
}
private void btn_fwd_Click_1(object sender, EventArgs e){
webBrowser1.GoForward();
txt_Url.Text = webBrowser1.Url.ToString();
}
private void btn_Stop_Click_1(object sender, EventArgs e){
webBrowser1.Stop();
}
private void btn_Refresh_Click_1(object sender, EventArgs e){
webBrowser1.Refresh();
}
private void btn_GO_Click_1(object sender, EventArgs e){
webBrowser1.Navigate(txt_Url.Text);
}
private void btn_Favourite_Click(object sender, EventArgs e){

}
}
}
Take 10 inputs from the user and assign them into two arrays (make 2 arrays of 5 lengths
each), merge those arrays and obtain the result in the sorted manner.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Merg
{
class Program
{
static void Main(string[] args)
{

int[] Ary1 = new int[5];


Console.WriteLine("Enter the 5 values of First Array array");
for (int i = 0; i < 5; i++)
{
Ary1[i] = int.Parse(Console.ReadLine());
}
int[] Ary2 = new int[5];
Console.WriteLine("Enter the 5 values of Second array");
for (int i = 0; i < 5; i++)
{
Ary2[i] = int.Parse(Console.ReadLine());
}
int[] Ary = new int[Ary1.Length + Ary2.Length];
Ary1.CopyTo(Ary, 0);
Ary2.CopyTo(Ary, Ary1.Length);
for (int i = 0; i < 9; i++)
{
int min = i;
for (int j = i + 1; j < 10; j++)
{
if (Ary[j] < Ary[min])
{
min = j;
}
}
}
Console.WriteLine("Sorting values by using merg sort");
for (int i = 0; i < 10; i++)
{
Console.Write("{0}",Ary[i]);
Console.Write(" ");
}
}
}
}

Output:

Create a class ElectricityBilling that contains a function which calculates total billing amount with the
help of inputs and displays the yearly bill as well. Take name, consumer_id, consumer_type as input,
where as pressure and consumed units are available by default as static members. Calculate the
monthly bill based on the type of consumer. Also display the yearly bill.

Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Atif
{

class ElectricityBilling
{
static string name, consumerId, consumerType;
static double pressure = 5.5;
static double consumerUnit=2.3;
public static void totalBill()
{

Console.Write("Enter Your Name :: ");


name= Console.ReadLine();
Console.Write("Enter Consumer Id :: ");
consumerId = Console.ReadLine();
Console.Write("Enter consumer Type :: ");
consumerType = Console.ReadLine();

double Month =( pressure * consumerUnit) * 1;


Console.WriteLine("Your Monthly Bill is :: "+Month);
double Yearly = (pressure * consumerUnit) * 12;
Console.WriteLine("Your Yearly Bill is :: "+Yearly);

class Program
{
static void Main(string[] args)
{
ElectricityBilling.totalBill();

}
}
}

Screen Shor
How to make Simple Phone Book

Code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PhoneBook
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
if (textBox1.Text == "" && textBox2.Text == "" && maskedTextBox1.Text.Length < 11)
MessageBox.Show("Enter Data in all fields");
else
{
dataGridView1.Rows.Add(textBox1.Text, textBox2.Text, maskedTextBox1.Text);
textBox1.Text = "";
textBox2.Text = "";
maskedTextBox1.Text = "";
textBox1.Focus();
}
}

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)


{
textBox3.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
textBox4.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
maskedTextBox2.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
}

private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)


{
DialogResult Result = MessageBox.Show("Do you really want to Delete???", "Confirmation",
MessageBoxButtons.YesNo);
if (Result == DialogResult.Yes)
{
dataGridView1.Rows.RemoveAt(dataGridView1.SelectedRows[0].Index);
}
}

private void button2_Click(object sender, EventArgs e)


{
if (textBox3.Text == "" && textBox4.Text == "" && maskedTextBox2.Text.Length < 11)
MessageBox.Show("Enter Data in all fields");
else
{
dataGridView1.SelectedRows[0].Cells[0].Value = textBox3.Text;
dataGridView1.SelectedRows[0].Cells[1].Value = textBox4.Text;
dataGridView1.SelectedRows[0].Cells[2].Value = maskedTextBox2.Text;
}
}

private void Form1_Load(object sender, EventArgs e)


{

}
}

Screen Shot
- See more at: http://softproweb.blogspot.in/2013/06/how-to-make-simple-phone-
book.html#sthash.SniZpsfq.dpuf

How to make a simple Age calculator in c#


Code

using System;

using System.Collections.Generic;

using System.ComponentModel;
using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace Age_Calculator

public partial class Form1 : Form

public Form1()

InitializeComponent();

private void button1_Click(object sender, EventArgs e)

DateTime dateOfBirth;

DateTime.TryParse(maskedTextBox1.Text, out dateOfBirth);

DateTime currentDate = DateTime.Now;

TimeSpan difference = currentDate.Subtract(dateOfBirth);

DateTime age = DateTime.MinValue + difference;

int ageInYears = age.Year - 1;

int ageInMonths = age.Month - 1;

int ageInDays = age.Day - 1;

textBox1.Text = (ageInYears).ToString();

textBox2.Text = (ageInMonths).ToString();

textBox3.Text = (ageInDays).ToString();

private void button1_MouseHover(object sender, EventArgs e)

{
toolTip1.SetToolTip(this.button1, "Enter to Calculate Your Age");

private void maskedTextBox1_MouseHover(object sender, EventArgs e)

toolTip1.SetToolTip(this.maskedTextBox1, "Enter your Birth Date");

private void button2_Click(object sender, EventArgs e)

Application.Exit();

private void button2_MouseHover(object sender, EventArgs e)

toolTip1.SetToolTip(this.button2, "Exit");

private void Form1_FormClosing(object sender, FormClosingEventArgs e)

DialogResult result;

result = MessageBox.Show("Do you realy want to close", "Confirmation",


MessageBoxButtons.YesNo);

if (result == DialogResult.No)

e.Cancel = true;

private void Form1_Load(object sender, EventArgs e)

}
- See more at: http://softproweb.blogspot.in/2013/04/how-to-make-simple-age-calculator-in-
c.html#sthash.5JLZ0j5r.dpuf

Real marksheet using HTML


Code:
<HTML>
<HEAD>
<STYLE>
body
{
border-radius: 20px;
border-style: double;
border-color: blue;
position: absolute;
width: 850px;
height: 705px;
top: 15px;
left: 45px;
padding: 30px 30px 50px 30px;
background-color: #CCC;
}
#tbl,#tbl2
{
border-collapse:collapse;
font-size:18;
font-family:Century Gothic;
}
.demo
{
position:absolute;
left:35px;
top:380px;
font-size:17;
font-family:Arial;
font-weight:bold;
margin-top:35px;
border-collapse:collapse;
}
#demoname
{
font-size:15px
}
.btn
{
position:absolute;
top:355px;
left:720px;
}
</STYLE>

<SCRIPT>
function myFun()
{
var a=document.form1.txtname.value;
document.getElementById("demoname").innerHTML=a;
var b=document.form1.txtfname.value;
document.getElementById("demofname").innerHTML=b;
var c=document.form1.txtins.value;
document.getElementById("demoins").innerHTML=c;
var d=document.form1.txtbatch.value;
document.getElementById("demobatch").innerHTML=d;
var e=document.form1.txtoffice.value;
document.getElementById("demooffice").innerHTML=e;
var f=document.form1.txtweb.value;
document.getElementById("demoweb").innerHTML=f;
var g=document.form1.txtit.value;
document.getElementById("demoit").innerHTML=g;
var h=document.form1.txtc.value;
document.getElementById("democ").innerHTML=h;
var txt1=eval(parseFloat(document.form1.txtoffice.value)+parseFloat(document.form1.txtweb.value)
+parseFloat(document.form1.txtit.value)+parseFloat(document.form1.txtc.value));
document.getElementById("demototal").innerHTML=txt1;
var txt2=eval(parseFloat(txt1*100)/400);
document.getElementById("demoper").innerHTML=txt2.toFixed(2)+"%";

switch(true)
{
case(txt2>=80):
document.getElementById("demograde").innerHTML="A1";
break;
case(txt2>=70):
document.getElementById("demograde").innerHTML="A";
break;
case(txt2>=60):
document.getElementById("demograde").innerHTML="B";
break;
case(txt2>=50):
document.getElementById("demograde").innerHTML="C";
break;
case(txt2>=40):
document.getElementById("demograde").innerHTML="D";
break;
case(txt2<40):
document.getElementById("demograde").innerHTML="Fail";
break;
}

}
</SCRIPT>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</HEAD>

<BODY>
<DIV class="color">
<H1 align="center"style="font-family:cambria;font-size:40";><U>STUDENT MARKSHEET</H1>
<FIELDSET>
<LEGEND> STUDENT INFORMATION </LEGEND>
<TABLE align="center" id="tbl">
<FORM name="form1">
</TR>
<TD width="140">Name:</TD> <TD><INPUT type="text" name="txtname"/></TD>
<TD> &nbsp; &nbsp;Father Name:</TD><TD> <INPUT type="text" name="txtfname"/></TD>
</TR>
<TR>
<TD width="140" > Institute Name:</TD><TD> <INPUT type="text" name="txtins"/></TD>
<TD style="text-indent:16px">Batch:</TD><TD> <INPUT type="text" name="txtbatch"/></TD>
</TR>
</TABLE>
</FIELDSET></BR>
<FIELDSET>
<LEGEND> SUBJECTS MARKS </LEGEND>
<TABLE id="tbl2">
<TR>
<TD> Office Automation:</TD><TD> <INPUT type="text" name="txtoffice" maxlength="2" size="10"/>
Out of 100 </TD>

</TR>
<TR>
<TD> Web Designing:</TD><TD> <INPUT type="text" name="txtweb" maxlength="2" size="10"/>
Out of 100</TD>
</TR>
<TR>
<TD> IT:</TD><TD> <INPUT type="text" name="txtit" maxlength="2" size="10"/> Out of 100</TD>
</TR>
<TR>
<TD> C# Programing:</TD><TD> <INPUT type="text" name="txtc" maxlength="2" size="10" /> Out of
100</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
</TR>
</TABLE>
</FIELDSET>
<DIV class="btn">
<button style="font-size:17" type="button" onclick='myFun()'>Submit</button>
<button style="font-size:17" type="Reset">Reset</button>
</DIV>
<DIV class="demo">
<TABLE border="1">
<TR>
<TH colspan="8" width="240"> Student Information </TH>
</TR>
<TR>
<TD width="135">Name:</TD><TD><FONT face="arial" id="demoname"></FONT></TD>
</TR>
<TR>
<TD width="135">Father Name:</TD><TD><FONT face="arial" id="demofname"></FONT></TD>
</TR>
<TR>
<TD width="135">Institute Name:</TD><TD><FONT face="arial" id="demoins"></FONT></TD>
</TR>
<TD width="135">Batch:</TD> <TD><FONT face="arial" id="demobatch"></FONT></TD>
</TR>
<TR>
<TH colspan="8" width="240"> Subjects Marks </TH>
</TR>
<TR>
<TD width="135">Office Automation:</TD> <TD><FONT face="arial"
id="demooffice"></FONT></TD>
</TR>
<TR>
<TD width="135">Web Designing:</TD><TD><FONT face="arial" id="demoweb"></FONT></TD>
</TR>
<TD width="135">IT:</TD><TD><FONT face="arial" id="demoit"></FONT></TD>
</TR>
<TR>
<TD width="135">C# Programing:</TD><TD><FONT face="arial" id="democ"></FONT></TD>
</TR>
<TR>
<TH colspan="8" width="240"> Marks Result </TH>
</TR>
<TR>
<TD width="135">TOTAL:</TD><TD> <FONT face="arial" id="demototal"></FONT></TT></TD>
</TR>
<TR>
<TD width="135">Percentage:</TD><TD><FONT face="arial" id="demoper"></FONT></TD>
</TR>
<TR>
<TD width="135">Grade:</TD><TD><FONT face="arial" id="demograde"></FONT></TD>
</TR>
</TABLE>
</DIV>
</DIV>

</BODY>
</HTML>

Screen Shot:

- See more at: http://softproweb.blogspot.in/2013/12/real-marksheet-using-


html.html#sthash.eV8CSXk0.dpuf
Create a class Student for student registration system using constructors. The class must include:
First name
Last name
Fathers name
Program
University = Bahria University
Address
Gender
Email
Campus
Semester

Initialize the following in the default constructor:


Program
Campus
Semester

Also write methods for getData() and displayData().

Code

sing System;
using System.Collections.Generic;
using System.Text;

namespace wasiq_khan
{

class DisplayData
{

string Programe, Campus, semister;

public DisplayData()
{
Programe = "Computer Science";
Campus = "Bahria University Karachi Campus";
semister = "4Th Semister";

}
public DisplayData(string FirstName, string Lastname, string Father
Name, string Address, string Gender, string Email)
{

Console.Write("My First Name is.... ");


FirstName = Console.ReadLine();
Console.Write("My Last Name is.... ");
Lastname = Console.ReadLine();
Console.Write("My Father Name is.... ");
FatherName = Console.ReadLine();

Console.Write("My Gender is.... ");


Gender = Console.ReadLine();
Console.Write("My Address is.... ");
Address = Console.ReadLine();
Console.Write("My Email.........");
Email = Console.ReadLine();
}

public void GetData()

Console.WriteLine("My Program is....."+Programe);


Console.WriteLine("My Semister is...."+semister);
Console.WriteLine("My Campus is.... "+Campus);

}
class Program
{
static void Main(string[] args)
{
string FiName="";
string Laname="";
string FName="";
string Addr="";
string Gend="";
string Ema="";

DisplayData obj = new DisplayData( FiName,Laname, FName,


Addr, Gend, Ema);

DisplayData ob = new DisplayData();


ob.GetData();

}
}

}
screen shot
- See more at: http://softproweb.blogspot.in/2013/05/how-to-make-student-information-
program.html#sthash.lB2cDQ6A.dpuf

Develop an application with one screen that calculates the monthly salary of an
employee. Your application should satisfy the following requirements:

1. Make sure you use all of the following components:


Label, TextBox, RadioButton, ComboBox, CheckBox, ListBox, Button, GroupBox
2. Employee Name: (TextBox)
3. Employee Grade Level: (ComboBox)
Director, Manager, Project Manager, Programmer
4. Basic Salary: (RadioButton)
30,000, 40,000, 50,000, 100,000
Basic Salary value should be read only and automatically selected based on the selected
Employee Grade Level
5. Benefits: (CheckBox)
Housing Allowance, Conveyance Allowance, Other Benefit 1, Other Benefit 2
(20000, 15000, 10000, 10000 respectively)
6. Bonuses: (ListBox)
Project Completion Bonus, Year End Bonus, Performance Bonus, Customer appreciation
Bonus
(20000, 30000, 25000, 15000)
7. Deductions: TextBox
Provident Fund Deduction, Medical Deduction
8. Calculate the Salary based on the user input regarding above features and display the
result

9. An Exit button.

Code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ClassLibrary1;

namespace lab3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
cal.Enabled = false;
}

private void Ext_Click(object sender, EventArgs e)


{
this.Close();
}

private void cal_Click(object sender, EventArgs e)


{

int sal = 0;

sal += int.Parse(cb2.Text);

if (c1.Checked == true)
sal += 5000;
if (c2.Checked == true)
sal += 5000;
if (c3.Checked == true)
sal += 5000;
if (c4.Checked == true)
sal += 5000;
sal += (10000 * lb1.SelectedIndices.Count);
if (c5.Checked == true)
sal -= 1500;

if (c6.Checked == true)
sal -= 2500;
tb2.Text = sal.ToString();

private void cb2_SelectedIndexChanged(object sender, E


ventArgs e)
{
if (tb1.Text != "" && cb1.SelectedIndex >= 0 &&
(r1.Checked == true || r2.Checked == true)
&& cb2.SelectedIndex >= 0 &&
lb1.SelectedIndices.Count > 0)
cal.Enabled = true;
}

private void cb1_SelectedIndexChanged(object sender, E


ventArgs e)
{
if (cb1.SelectedIndex == 0)
cb2.SelectedIndex = 4;
if (cb1.SelectedIndex == 1)
cb2.SelectedIndex = 3;
if (cb1.SelectedIndex == 2)
cb2.SelectedIndex = 2;
if (cb1.SelectedIndex == 3)
cb2.SelectedIndex = 1;
if (tb1.Text != "" && cb1.SelectedIndex >= 0 &&
(r1.Checked == true || r2.Checked == true)
&& cb2.SelectedIndex >= 0 &&
lb1.SelectedIndices.Count > 0)
cal.Enabled = true;

private void tb1_TextChanged(object sender, EventArgs


e)
{
if (tb1.Text != "" && cb1.SelectedIndex >= 0 &&
(r1.Checked == true || r2.Checked == true)
&& cb2.SelectedIndex >= 0 &&
lb1.SelectedIndices.Count > 0)
cal.Enabled = true;
}

private void gb1_Enter(object sender, EventArgs e)


{
}

private void lb1_SelectedIndexChanged(object sender, E


ventArgs e)
{
if (tb1.Text != "" && cb1.SelectedIndex >= 0 &&
(r1.Checked == true || r2.Checked == true)
&& cb2.SelectedIndex >= 0 &&
lb1.SelectedIndices.Count > 0)
cal.Enabled = true;
}

private void r1_CheckedChanged(object sender, EventArg


s e)
{
if (tb1.Text != "" && cb1.SelectedIndex >= 0 &&
(r1.Checked == true || r2.Checked == true)
&& cb2.SelectedIndex >= 0 &&
lb1.SelectedIndices.Count > 0)
cal.Enabled = true;
}

private void r2_CheckedChanged(object sender, EventArg


s e)
{
if (tb1.Text != "" && cb1.SelectedIndex >= 0 &&
(r1.Checked == true || r2.Checked == true)
&& cb2.SelectedIndex >= 0 &&
lb1.SelectedIndices.Count > 0)
cal.Enabled = true;
}

private void button1_Click(object sender, EventArgs e)


{
Class1 asd = new Class1();
int x = asd.fn(3);
tb1.Text = x.ToString();
}

}
}

Screen Shot
- See more at: http://softproweb.blogspot.in/2013/05/develop-application-with-one-
screen.html#sthash.QW03ihhv.dpuf

Resume in Html

Code
<html >
<head>
<title>Resume Of Waqeeh Ul Hasan</title>
</head>
<body>
<h3> Resume Of <h1>Waqeeh Ul Hasan</h3>
<p>
<img border="0" src="http://lh6.ggpht.com/-
kYxgHwfb6V4/UawlWdsss_I/AAAAAAAAApo/M_TMAnnkYao/
166571_367932973267402_1468747437_n.jpg" alt="Pulpit rock" width="74" height="78">
<br>123 Gulshan-e-Iqbal Block 10/A<br>
Karachi, Pakistan and 75360
</p><p>
111 999 111<br>
Resum@gmail.com
</p> <hr>
<h2>Skills</h2><ol>
<li> Web Design </li>
<li> Interface Desig </li>
<li> Project Direction</li>
</ol><hr><h2>Technical </h2>
<ol>
<li> XHML </li>
<li> CSS </li>
<li> Javascript </li>
<li> Jquery </li>
<li> PHP</li>
<li> Windows Server 2008 </li>
</ol><hr>

<h2> Educational Background </h2>


<h3>Primary Education </h3>

<p> Bahria college NORE 1 </p>


<h3> Secondary Education </h3>
<p> Bahria college NORE 1 </p>
<h3> Higher education </h3>
<p> Bahria university karachi campus </p>

<hr><h2> Job Experience </h2>


<p> 1 year experience in a Food Court</p>
<p> 2 year experience in a Vogure office </p><hr>
</body>

</html>

Screen Shot
LAB 02:
Lab Tasks:
4. Change the value of width in <HR> tag from 50% to 80%. Attach printout of modified page.

Code
<html >
<head>
<title>Resume Of Waqeeh Ul Hasan</title>
</head>
<body>

<h3> <center> Resume Of <h1>Waqeeh Ul Hasan <center> </h3>


<h2>Personal Information </h2>
<table border="3">
<tr>
<td>
123 Gulshan-e-Iqbal Block 10 Karachi, Pakistan and 75360
</td>
<tr>
<td>
111 999 111
</td>
</tr>
<td>
Resum@gmail.com
</td>
</tr>
</table>
</p> <hr>
<h2>Skills</h2>
<table border="3">
<tr>
<td> Web Design
</td>
</tr>
<tr>
<td>Interface Design
</td> </tr>
<tr><td>
Project Direction </td>
</tr> </table>
</body>
</html>

Screen Shot:
4. Write a code for HTML page with the <ELEMENT>, <H>, <B>, <P>, <A>, <BR> and
<HR> tags.
Code:
<html >
<head>
<title>Resume Of Waqeeh Ul Hasan</title>
</head>
<body>

<h3> <center> Resume Of <h1>Waqeeh Ul Hasan <center> </h3>


<hr>
<h2>Personal Information </h2>
<table border="3">
<tr>
<td>
123 Gulshan-e-Iqbal Block 10 Karachi, Pakistan and 75360
</td>
<tr>
<td>
<b> 111 999 111 </b>
</td></tr>
<td> <a href="Resum@gmail.com">Resum@gmail.com</a>
</td>
</tr>
</table>
</p> <hr>
<h2>Skills </h2>
<table border="3">
<tr>
<td> Web Design </td>
</tr><tr>
<td>Interface Design </td>
</tr><tr>
<td> Project Direction </td>
</tr> </table>
<hr> </body>
</html>

Screen Shot:

- See more at: http://softproweb.blogspot.in/2013/11/resume-in-html.html#sthash.qum866yb.dpuf

Create Signup page with Validation using JavaScript - See more at:
http://softproweb.blogspot.in/2013/12/create-signup-page-with-validation.html#sthash.bgCRBOi9.dpuf

Code:
<html>
<head>

<title>Signup || Nested-code team</title>


<style type="text/css">
<!--
body {
margin-left: 150px;
margin-top: 5px;
margin-right: 190px;
background-color: #966;
}
-->
</style>
<script language="javascript">
function check()
{

if(document.form1.lid.value=="")
{
alert("Plese Enter Login Id");
document.form1.lid.focus();
return false;
}

if(document.form1.pass.value=="")
{
alert("Plese Enter Your Password");
document.form1.pass.focus();
return false;
}
if(document.form1.cpass.value=="")
{
alert("Plese Enter Confirm Password");
document.form1.cpass.focus();
return false;
}
if(document.form1.pass.value!=document.form1.cpass.value)
{
alert("Confirm Password does not matched");
document.form1.cpass.focus();
return false;
}
if(document.form1.name.value=="")
{
alert("Plese Enter Your Name");
document.form1.name.focus();
return false;
}
if(document.form1.address.value=="")
{
alert("Plese Enter Address");
document.form1.address.focus();
return false;
}
if(document.form1.city.value=="")
{
alert("Plese Enter City Name");
document.form1.city.focus();
return false;
}
if(document.form1.phone.value=="")
{
alert("Plese Enter Contact No");
document.form1.phone.focus();
return false;
}
if(document.form1.email.value=="")
{
alert("Plese Enter your Email Address");
document.form1.email.focus();
return false;
}
e=document.form1.email.value;
f1=e.indexOf('@');
f2=e.indexOf('@',f1+1);
e1=e.indexOf('.');
e2=e.indexOf('.',e1+1);
n=e.length;

if(!(f1>0 && f2==-1 && e1>0 && e2==-1 && f1!=e1+1 && e1!=f1+1 && f1!=n-1 && e1!=n-1))
{
alert("Please Enter valid Email");
document.form1.email.focus();
return false;
}
return true;
}

</script>
<link href="quiz.css" rel="stylesheet" type="text/css">
<style type="text/css">
body,td,th {
color: #C30;
}
a:link {
color: #06F;
}
a:visited {
color: #06F;
}
.d {
color: #0F0;
}
.dff {
color: #00F;
}
.y {
color: #FF0;
}
.style7 {
color: #0F0;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body><center></center>
<br>
<table width="100%" height="534" border="0">
<tr>
<td width="206" rowspan="2" valign="top">&nbsp;</td>
<td width="651" height="57"><h1 align="left"><span class="d">New</span> <span
class="dff">User</span><span class="style8"> <span class="y">Signup</span></span></h1></td>
</tr>
<tr>
<td><form name="form1" method="post" action=" " onSubmit="return check();">
<table width="532" height="341" border="0" align="left" bordercolor="#CCFF99"
bordercolordark="#00CCFF" cellpadding="2" cellspacing="3" >
<tr>
<td><div align="left" class="style7">Login Id </div></td>
<td><input type="text" name="lid"></td>
</tr>
<tr>
<td class="style7">Password</td>
<td><input type="password" name="pass"></td>
</tr>
<tr>
<td class="style7">Confirm Password </td>
<td><input name="cpass" type="password" id="cpass"></td>
</tr>
<tr>
<td class="style7">Name</td>
<td><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td valign="top" class="style7">Address</td>
<td><textarea name="address" id="address"></textarea></td>
</tr>
<tr>
<td valign="top" class="style7">City</td>
<td><input name="city" type="text" id="city"></td>
</tr>
<tr>
<td valign="top" class="style7">Phone</td>
<td><input name="phone" type="text" id="phone"></td>
</tr>
<tr>
<td valign="top" class="style7">E-mail</td>
<td><input name="email" type="text" id="email"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Signup">
</td>
</tr>
</table>
</form></td>
</tr>
</table>

<br><br><br><br><br>
<center></center>
</body>
</html>

Screen Shot:
- See more at: http://softproweb.blogspot.in/2013/12/create-signup-page-with-
validation.html#sthash.bgCRBOi9.dpuf

HTML Validation with Javascript

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CoOl Javascript Validation</title>
<script type="text/javascript" src="cvalidate.js"></script>
<style type="text/css">
.heading
{
color:#0099FF;
font-weight:bolder;
font-size:20px;
}
.txt
{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:12px;
}
</style>

</head>

<body>

<form name="frmValidate" id="myform" action="" method="post" onsubmit="return


validateForm('myform',true)">
<table width="350" border="0" cellspacing="0" cellpadding="5" align="center" bgcolor="#F4FAFF"
style="border:1px solid #0099FF;">
<tr>
<td colspan="2" class="heading" align="center" style="border-bottom:1px solid #0099FF;"><a
href="http://softproweb.blogspot.com/">Submit Form</a></td>
</tr>
<tr>
<td colspan="2" class="heading" align="center" height="10"></td>
</tr>

<tr>
<td align="left" class="txt">Username *</td>
<td align="right"><input type="text" name="username" id="username" size="28" title="Username"
class="required alpha" /></td>
</tr>
<tr>
<td align="left" class="txt">Password *</td>
<td align="right"><input type="password" name="password" id="password" size="28"
title="Password" class="required alpha min 6 max 20 match cpassword" /></td>
</tr>
<tr>
<td align="left" class="txt">Confirm Password *</td>
<td align="right"><input type="password" name="cpassword" id="cpassword" size="28" title="Confirm
Password" class="required alpha" /></td>
</tr>

<tr>
<td align="left" class="txt">First Name *</td>
<td align="right"><input type="text" name="fname" id="fname" size="28" title="First Name"
class="required text" /></td>
</tr>
<tr>
<td align="left" class="txt">Last Name</td>
<td align="right"><input type="text" name="lname" id="lname" size="28" title="Last Name" /></td>
</tr>
<tr>
<td align="left" class="txt">Age *</td>
<td align="right"><input type="text" name="age" id="age" size="28" title="Age" class="required
number min 10 max 100 " /></td>
</tr>
<tr>
<td align="left" class="txt">Email *</td>
<td align="right"><input type="text" name="email" id="email" size="28" title="Email" class="required
email" /></td>
</tr>
<tr>
<td align="left" class="txt">Phone *</td>
<td align="right"><input type="text" name="phone" id="phone" size="28" title="Phone"
class="required regex ^\-?\d+$" /></td>
</tr>
<tr>
<td align="left" class="txt">Fax</td>
<td align="right"><input type="text" name="fax" id="fax" size="28" title="Fax" /></td>
</tr>
<tr>
<td align="left" class="txt">Date Of Birth *</td>
<td align="right"><input type="text" name="dob" id="dob" size="28" title="Date Of Birth"
class="required date" /></td>
</tr>
<tr>
<td align="left" class="txt">Website *</td>
<td align="right"><input type="text" name="website" id="website" size="28" title="Website"
class="required web" /></td>
</tr>
<tr>
<td align="left" class="txt">Country *</td>
<td align="left">&nbsp;
<select name="country" id="country" title="Country" class="required">
<option value="">--- Select ---</option>
<option value="Canada">Canada</option>
<option value="UK">UK</option>
<option value="USA">USA</option>
<option value="Pakistan">Pakistan</option>
<option value="Other">Other</option>
</select>
</td>
</tr>
<tr>
<td align="left" class="txt">Gender *</td>
<td align="left">
<input type="radio" name="gender" value="m" title="Gender" class="required" />Male
<input type="radio" name="gender" value="f" title="Gender" class="required" />Female
</td>
</tr>

<tr>
<td align="left" class="txt">Disclaimer *</td>
<td align="left">
<input type="checkbox" name="disclaimer" value="1" title="Disclaimer" class="required" />
</td>
</tr>
<tr>
<td align="right" colspan="2">
<input type="submit" name="btnSubmit" value="Submit Form" />
</td>
</tr>

</table>
</form>
<br /><br />

Screen Shot:
- See more at: http://softproweb.blogspot.in/2013/12/html-validation-with-
javascript.html#sthash.aLi3sUTE.dpuf

How to make fancy table in html

Code:
<head>
<title>
lab 7 task 1
</title>
<style>
.o{
color: #F30;
border-color: blue;
}
#a{background-color:grey;}
</style>
</head>

<body>
<table border="0" align="center" cellspacing="4" cellpadding="2" witdh="100%" height="40%">

<th class="o">ID</th>
<th class="o">NAME</th>
<th class="o">OCCUPATION</th>
<th class="o">APPROX.LOCATION</th>
<th class="o">PRICE</th>

<tr id="a">
<td>203A</td>
<td>Hasan<A HREF="http://softproweb.blogspot.com/">(bio)</A></td>
<td>Front-man</td>
<td>Los Angeles</td>
<td>$39.95</td>
</tr>

<tr>
<td>141B</td>
<td>Amir<A HREF="http://softproweb.blogspot.com/">(pic.bio)</A></td>
<td>Singer</td>
<td>Newyork</td>
<td>$39.95</td>
</tr>

<tr id="a">
<td>2031</td>
<td>Zain<A HREF="http://softproweb.blogspot.com/">(pic)</A></td>
<td>Producer</td>
<td>Newyork</td>
<td>$19.95</td>
</tr>

<tr>
<td>007F</td>
<td>Kashif<A HREF="http://softproweb.blogspot.com/">(bio.press)</A></td>
<td>Singer</td>
<td>Omaha</td>
<td>$11.95</td>
</tr>

<tr id="a">
<td>8A05</td>
<td>Faisal<A HREF="http://softproweb.blogspot.com/">(pic)</A></td>
<td>DJ</td>
<td>London</td>
<td>$19.95</td>
</tr>

<tr>
<td>6636</td>
<td>talha<A HREF="http://softproweb.blogspot.com/">(bio.press)</A></td>
<td>Keytarist</td>
<td>London</td>
<td>$39.95</td>
</tr>

</table>
</body>
Screen Shot:

- See more at: http://softproweb.blogspot.in/2013/12/how-to-make-fancy-table-in-


html.html#sthash.jUlYPYYx.dpuf

using System;

public abstract class Employee


{
public abstract string Name
{
get;
}
}
class Engineer: Employee
{
string name = "Engineer";

public override string Name


{
get
{
return(name);
}
}
}
class MainClass
{
public static void Main()
{
Employee d = new Engineer();
Console.WriteLine("Name: {0}", d.Name);
}
}
Name: Engineer

using System;

public interface InterfaceA


{
void MethodA();
}

public interface InterfaceB : InterfaceA


{
new void MethodA(); // hides MethodA() in InterfaceA
}

public class MyClass : InterfaceB


{

void InterfaceB.MethodA()
{
Console.WriteLine("InterfaceB implementation of MethodA()");
}

public void MethodA()


{
Console.WriteLine("InterfaceA implementation of MethodA()");
}

class MainClass
{
public static void Main()
{
MyClass myClass = new MyClass();

Console.WriteLine("Calling myClass.MethodA()");
myClass.MethodA();

InterfaceB mySteerable = myClass as InterfaceB;


Console.WriteLine("Calling mySteerable.MethodA()");
mySteerable.MethodA();

InterfaceA myDrivable = myClass as InterfaceA;


Console.WriteLine("Calling myDrivable.MethodA()");
myDrivable.MethodA();

}
Calling myClass.MethodA()
InterfaceA implementation of MethodA()
Calling mySteerable.MethodA()
InterfaceB implementation of MethodA()
Calling myDrivable.MethodA()
InterfaceA implementation of MethodA()
using System;

interface InterfaceOne
{
void Execute();
}

interface InterfaceTwo
{
void Execute();
}

class MyImplementation: InterfaceOne, InterfaceTwo


{
void InterfaceOne.Execute()
{
Console.WriteLine("InterfaceOne.Execute implementation");
}
void InterfaceTwo.Execute()
{
Console.WriteLine("InterfaceTwo.Execute implementation");
}
}

class MainClass
{
public static void Main()
{
MyImplementation MyImplementation = new MyImplementation();

InterfaceOne InterfaceOne = (InterfaceOne) MyImplementation;


InterfaceOne.Execute();
InterfaceTwo InterfaceTwo = (InterfaceTwo) MyImplementation;
InterfaceTwo.Execute();
}
}
InterfaceOne.Execute implementation
InterfaceTwo.Execute implementation

using System;

interface InterfaceOne
{
void Execute();
}

interface InterfaceTwo
{
void Execute();
}

class MyImplementation: InterfaceOne, InterfaceTwo


{
void InterfaceOne.Execute()
{
Console.WriteLine("InterfaceOne.Execute implementation");
}
void InterfaceTwo.Execute()
{
Console.WriteLine("InterfaceTwo.Execute implementation");
}

public void Execute()


{
((InterfaceOne) this).Execute();
}
}

class MainClass
{
public static void Main()
{
MyImplementation MyImplementation = new MyImplementation();

MyImplementation.Execute();
}
}
InterfaceOne.Execute implementation

using System;

class MyClass
{
static int myValue;

public static int StaticProperty


{
set { myValue = value; }
get { return myValue; }
}

class MainClass
{
static void Main()
{
Console.WriteLine("Init Value: {0}", MyClass.StaticProperty);
MyClass.StaticProperty = 10;
Console.WriteLine("New Value : {0}", MyClass.StaticProperty);
}
}
Init Value: 0
New Value : 10

using System;

class MyClass
{
class MyCounter
{
public int Count = 0;
}

private MyCounter counter;

public MyClass() {
counter = new MyCounter();
}
public int Incr() {
return counter.Count++;
}
public int GetValue() {
return counter.Count;
}
}

class MainClass
{
static void Main()
{
MyClass mc = new MyClass();

mc.Incr();
mc.Incr();
mc.Incr();
mc.Incr();
mc.Incr();
mc.Incr();

Console.WriteLine("Total: {0}", mc.GetValue());


}
}
Total: 6

using System;

class MainClass
{
delegate int MyDelegate(string s);
static void Main(string[] args)
{
string MyString = "Hello World";

MyDelegate Multicast = null;

Multicast += new MyDelegate(DoSomething);


Multicast += new MyDelegate(DoSomething2);

Multicast(MyString);
}
static int DoSomething(string s)
{
Console.WriteLine("DoSomething");

return 0;
}
static int DoSomething2(string s)
{
Console.WriteLine("DoSomething2");
return 0;
}
}
DoSomething
DoSomething2

using System;

class MainClass
{
delegate int MyDelegate(string s);
static void Main(string[] args)
{
string MyString = "Hello World";

//Or you can Multicast delegates by doing this


MyDelegate Multicast = null;

Multicast += new MyDelegate(DoSomething);


Multicast += new MyDelegate(DoSomething2);

Multicast -= new MyDelegate(DoSomething2);


Multicast(MyString);
}

static int DoSomething(string s)


{
Console.WriteLine("DoSomething");

return 0;
}
static int DoSomething2(string s)
{
Console.WriteLine("DoSomething2");
return 0;
}
}
DoSomething

using System;

delegate void FunctionToCall();

class MyClass
{
public void nonStaticMethod()
{
Console.WriteLine("nonStaticMethod");
}

public static void staticMethod()


{
Console.WriteLine("staticMethod");
}
}

class MainClass
{
static void Main()
{
MyClass t = new MyClass();
FunctionToCall functionDelegate;
functionDelegate = t.nonStaticMethod;

functionDelegate += MyClass.staticMethod;
functionDelegate += t.nonStaticMethod;
functionDelegate += MyClass.staticMethod;

functionDelegate();
}
}
nonStaticMethod
staticMethod
nonStaticMethod
staticMethod

using System;

delegate void FunctionToCall();

class MyClass
{
public void nonStaticMethod()
{
Console.WriteLine("nonStaticMethod");
}

public static void staticMethod()


{
Console.WriteLine("staticMethod");
}
}

class MainClass
{
static void Main()
{
MyClass t = new MyClass();
FunctionToCall functionDelegate;
functionDelegate = t.nonStaticMethod;

functionDelegate += MyClass.staticMethod;
functionDelegate += t.nonStaticMethod;
functionDelegate += MyClass.staticMethod;

functionDelegate();
}
}
nonStaticMethod
staticMethod
nonStaticMethod
staticMethod

using System;

delegate int FunctionToCall();


class MainClass
{
static int IntValue = 5;

public static int Add2() {


IntValue += 2;
return IntValue;
}

public static int Add3() {


IntValue += 3;
return IntValue;
}

static void Main()


{
FunctionToCall functionDelegate = Add2;
functionDelegate += Add3;
functionDelegate += Add2;

Console.WriteLine("Value: {0}", functionDelegate());


}
}
Value: 12

using System;

public delegate string DelegateDescription();

public class Person


{
private string name;
private int age;
public Person(string name, int age)
{
this.name = name;
this.age = age;
}

public string NameAndAge()


{
return(name + " is " + age + " years old");
}

public class Employee


{
private string name;
private int number;
public Employee(string name, int number)
{
this.name = name;
this.number = number;
}

public string MakeAndNumber()


{
return(name + " is " + number + " mph");
}
}

class MainClass
{
public static void Main()
{
Person myPerson = new Person("Price", 32);
DelegateDescription myDelegateDescription = new
DelegateDescription(myPerson.NameAndAge);

string personDescription = myDelegateDescription();


Console.WriteLine("personDescription = " + personDescription);

Employee myEmployee = new Employee("M", 140);

myDelegateDescription = new DelegateDescription(myEmployee.MakeAndNumber);

string d = myDelegateDescription();
Console.WriteLine(d);
}
}
personDescription = Price is 32 years old
M is 140 mph

using System;

delegate string StrMod(string str);

class MainClass {

static string replaceSpaces(string a) {


Console.WriteLine("replaceSpaces");
return a;
}

static string removeSpaces(string a) {


Console.WriteLine("removeSpaces");
return a;
}

static string reverse(string a) {


Console.WriteLine("reverseSpaces");
return a;
}

public static void Main() {


StrMod strOp = new StrMod(replaceSpaces);
string str;

str = strOp("This is a test.");

strOp = new StrMod(removeSpaces);


str = strOp("This is a test.");

strOp = new StrMod(reverse);


str = strOp("This is a test.");
}
}
replaceSpaces
removeSpaces
reverseSpaces

using System;

delegate string StrMod(string str);

class MainClass {

static string replaceSpaces(string a) {


Console.WriteLine("replaceSpaces");
return a;
}

static string removeSpaces(string a) {


Console.WriteLine("removeSpaces");
return a;
}

static string reverse(string a) {


Console.WriteLine("reverseSpaces");
return a;
}

public static void Main() {

StrMod strOp = replaceSpaces; // use method group conversion


string str;

// Call methods through the delegate.


str = strOp("This is a test.");

strOp = removeSpaces; // use method group conversion


str = strOp("This is a test.");

strOp = reverse; // use method group converison


str = strOp("This is a test.");
}

}
replaceSpaces
removeSpaces
reverseSpaces

using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

delegate void FooBar();

public class MainClass


{
static void Invoke3Times(FooBar d)
{
d(); d(); d();
}

public static void Main(){


int i = 0;
Invoke3Times(delegate { i++; });
Console.WriteLine(i);

}
3