HUMAN

July 30, 2008

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace Human

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

Human x = new Human();

x.Name = textBox1.Text;

x.Gender = comboBox1.Text;

MessageBox.Show(x.Talk());

}

}

}

 

HUMAN.cs

using System;

using System.Collections.Generic;

using System.Text;

namespace Human

{

class Human

{

public enum HumanType

{

Male,

Female

}

private string name;

private string gender;

public static int humanCount = 0;public Human()

{

humanCount++;

}

public string Name

{

get

{

return name;

}

set

{

this.name = value;

}

}

public string Gender

{

get

{

return gender;

}

set

{

this.gender = value;

}

}

public string Talk()

{

return "Hello! my name is " + name + " and i am a " + gender+ ".\nCurrent number of instance of human "+ humanCount;

}

}

}

ovveride and virtual sample

July 29, 2008

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

namespace CA
{
    class Program
    {
        class A
        {
            public virtual void WhoAreYou()
            {
                Console.WriteLine("I am an A");
            }
        }
        class B: A
        {
            public override void WhoAreYou()
            {
                Console.WriteLine("I am a B");
            }
        }
        class C : B
        {
            public new virtual void WhoAreYou()
            {
                Console.WriteLine("I am a C");
            }
        }
        class D : C
        {
            public override void WhoAreYou()
            {
                Console.WriteLine("I am a D");
            }
        }
        static void Main(string[] args)
        {
            C c = new D();
            c.WhoAreYou();
            A a = new D();
            a.WhoAreYou();
            Console.ReadLine();
        }        
    }

}

students.cs

July 23, 2008

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

namespace ConsoleApplication1
{
class Student
{

public int x = 0;
public enum Course
{
IT,
IM,
CS,
IS,
Undefined
}
public enum Subject
{
Undefined,
System_Prog,
Software_Engr,
Discrete_Math,
IT_Fundamentals,
C_Prog
}

private string name;
private Course course;
private Subject[] s1 = new Subject[3];

public Student()
{
}

public Student(string name, Course course)
{
this.name = name;
this.course = course;
}

public string Name
{
get
{
return name;
}
set
{
name = value;
}
}

public Course _Course
{
get
{
return course;
}
set
{
course = value;
}
}

public void Enroll(Subject load)
{
if (s1[0] == Subject.Undefined)
{
s1[0] = load;
// Console.WriteLine(”Student can only enroll 3 subjects for this semester.”);
}
else if (s1[0] != Subject.Undefined && s1[1] == Subject.Undefined)
{
s1[1] = load;
// Console.WriteLine(”Student can only enroll 3 subjects for this semester.”);
}
else if (s1[0] != Subject.Undefined && s1[2] == Subject.Undefined)
{
s1[2] = load;
// Console.WriteLine(”Student can only enroll 3 subjects for this semester.”);
}
else
{
Console.WriteLine(”Student can only enroll 3 subjects for this semester.”);

}
}

public void Modify(Subject a, Subject b)
{
for (int x = 0; x < 3; x++)
{
if (b == s1[x])
{
Console.WriteLine(”Student can only enroll 3 subjects for this semester.”);
}
}

}

public void ShowOutput()
{

Console.WriteLine(”Name: ” + name + “Course: ” + course + ” Subject: “);
if (s1[0] == Subject.Undefined)
{
Console.Write(” “);
}
else
{
Console.Write(s1[0]);
}

if (s1[1] == Subject.Undefined)
{
Console.Write(” “);
}
else
{
Console.Write(s1[1]);
}

if (s1[2] == Subject.Undefined)
{
Console.Write(” “);
}
else
{
Console.Write(s1[2]);
}

Console.WriteLine();

//else if (s1[1] == Subject.Undefined)
//{
// Console.Write(” “);
//}
// Console.WriteLine(”Name: ” + name + “Course: ” + course + ” Subject: ” +s1[0]+s1[1]+s1[2]);

// //else
// //{
// // Console.Write(s1[c]);
// //}
////for (int c = 0; c < 3; c++)
//// {
//// if (s1[c] != Subject.Undefined)
//// {
//// Console.Write(s1[c]);
//// }
//// else
//// {
//// Console.Write(” “);
//// }
//// }
//}

}
}
}

REGEX

July 9, 2008
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;

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

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string str = textBox2.Text;
            string find = textBox1.Text;

            MatchCollection Matches = Regex.Matches(str, find, RegexOptions.IgnoreCase);
            listBox1.Items.Clear();
            this.listBox1.Items.Add(textBox1.Text.ToString());

        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            string str = textBox2.Text;
            string find = textBox1.Text;

            MatchCollection Matches = Regex.Matches(str, find, RegexOptions.IgnoreCase);
            listBox1.Items.Clear();
            foreach (Match NextMatch in Matches)
            {
                this.listBox1.Items.Add(NextMatch.ToString());
            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
            string str = textBox2.Text;
            string find = textBox1.Text;

            MatchCollection Matches = Regex.Matches(str, find, RegexOptions.IgnoreCase);
            listBox1.Items.Clear();
            if (Matches.Count == 0)
            {
                listBox1.Items.Add("There are no matches");
            }
            else
                listBox1.Items.Add("Matches found");
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

time span

July 7, 2008

using System;

using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

public enum AgeGroup

{

Baby, Child, Teen, Adult

}

static void Main(string[] args)

{

string Name;

Console.Write("Name:");

Name = Console.ReadLine();

Console.Write("BirthDate : ");

//int age = 2008 - date.Year;

DateTime date = DateTime.Parse(Console.ReadLine());

int age = 2008 - date.Year;

TimeSpan t = DateTime.Now.Subtract(date);

age = t.Days / 365; if (age < 0)

{

Console.WriteLine("Hello " + Name + " Invalid input");

}

// Console.WriteLine("Hello." + Name);

Console.WriteLine("Hello" + Name + " You are " + age + " years old" + " You are a");

if (age <= 1 && age >= 0)

{

Console.Write(AgeGroup.Baby + ".");

}

if (age <= 12 && age >= 2)

{

Console.Write(AgeGroup.Child + ".");

}

if (age <= 19 && age >= 13)

{

Console.Write(AgeGroup.Teen + ".");

}

else if (age <= 20 && age >= 135)

{

Console.Write(AgeGroup.Adult + ".");

}

if (age > 135)

{

Console.WriteLine("Hello " + Name + ".. Invalid input");

}

Console.ReadLine();

}

}

}

DESKTOP

July 3, 2008

Motherboard—————————————-

Asrock ALive NF7G-HD720p R5.0

CPU—————————————–

AMD Athlon™ X2 Dual-Core

Printer—————————————–

HP D2460

OR

HP D1460

And ………….

160GB HDD

1GB RAM

LCD 17” inch (SAMSUNG)

DVD COMBO

 

Package Accessories

-AVR

-mouse

-keyboard

-speaker

-CD Ink pen

-Headset with Microphone