c# programs
c# programs
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 _1darray
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
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 abstraction
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
class Test
{
int x, y;
public void Read(int a, int b)
{
x = a;
y = b;
}
public void print() {
int k = x + y;
MessageBox.Show("the value is: " + k.ToString());
}
}
private void button1_Click(object sender, EventArgs e)
{
Test t = new Test();
MessageBox.Show(t.GetHashCode().ToString());
MessageBox.Show(t.GetType().Name);
t.Read(20,30);
t.print();
Test t1 = new Test();
t1.print();
Test t2 = t;
t2.print();
}
}
}
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 boxing
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
else
{
this.BackColor = Color.Red;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace c__styleoftypecaset
{
internal class Program
{
static void Main(string[] args)
{
Console.Write("hello world");
Console.WriteLine("hello planet");
Console.WriteLine("DateTime: "+"\n"+DateTime.Now.ToString());
Console.Read();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace C__typecaste2
{
internal class Program
{
static void Main(string[] args)
{
int i = 100;
byte s = (byte)i;
Console.WriteLine("the value of s is: " + s);
Console.Read();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace constructor_and_destructor
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
class Test
{
public Test()
{
MessageBox.Show("from constructor");
}
~Test()
{
MessageBox.Show("from destructor");
}
}
private void button1_Click(object sender, EventArgs e)
{
Test t= new Test();
}
}
}
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 dowhile
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
while (i <= 2);
MessageBox.Show("the sum is: " + sum);
}
}
}
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 encap
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
class Emp
{
int sal = 5000;
public void increment(int sal)
{
this.sal = this.sal + sal;
}
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 enums
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
enum test
{
A,
B = 10,
C
}
private void button1_Click(object sender, EventArgs e)
{
int i, j, k;
i = (int)test.A;
j = (int)test.B;
k = (int)test.C;
MessageBox.Show(i + "\n" + j + "\n" + k);
}
}
}
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 @foreach
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
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 forloop
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
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 forloop1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
}
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 function_overloading
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
class Test
{
public void show(float x)
{
MessageBox.Show("from float:" + x.ToString());
}
public void show(double x)
{
MessageBox.Show("from double:" + x.ToString());
}
public void show(decimal x)
{
MessageBox.Show("from decimal:" + x.ToString());
}
public void show(int x)
{
MessageBox.Show("from integer:"+x.ToString());
}
public void show(string x)
{
MessageBox.Show("from string:" + x.ToString());
}
private void button1_Click(object sender, EventArgs e)
{
Test t = new Test();
t.show(4.5m);
t.show(4.5d);
t.show(4.5f);
t.show(1000);
t.show("hello");
}
}
}
}
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 inheritance
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
class Employee
{
private int EmpNo = 101;
private string EmpName = "venkat";
private string Department = "LDS";
private string designation = "CM";
private string Address = "mylapore";
private string Email = "[email protected]";
protected int salary = 5000;
}
else
{
Employee emp = new Employee();
emp.print();
}
}
}
}
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 jaggedarray
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
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 multidimarray
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
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 operator_overloading
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
class Test
{
private string s;
public Test(string a) {
s = a;
}
public static string operator +(Test x, Test y)
{
string abc =x.s + y.s;
return abc;
}
}
private void button1_Click(object sender, EventArgs e)
{
Test t1 =new Test("hello");
Test t2 =new Test("hello WORLD");
string t3 = t1 + t2;
MessageBox.Show(t3.ToString());
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace parsing
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine(int.MinValue.ToString());
Console.WriteLine(int.MaxValue.ToString());
Console.WriteLine(DateTime.MinValue.ToString());
Console.WriteLine(DateTime.MaxValue.ToString());
Console.WriteLine(Decimal.MinValue.ToString());
Console.WriteLine(Decimal.MaxValue.ToString());
Console.ReadLine();
}
}
}
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 @static
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
class Test
{
private static int i;//instance variable
private static int s;//static variable
static Test()
{
s = 0;
i = 0;
//by default i = 0;
}
public Test()
{
i = i + 1;
s = s + 1;
MessageBox.Show(i.ToString() + "\n" + s.ToString());
}
private void button1_Click(object sender, EventArgs e)
{
Test t1 = new Test();
Test t2 = new Test();
Test t3 = new Test();
}
}
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 statickeyword1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
static class test
{
public static void show(string s)
{
MessageBox.Show(s);
}
}
private void button1_Click(object sender, EventArgs e)
{
test.show("hello good morning");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace typecast3
{
internal class Program
{
static void Main(string[] args)
{
char c = '?';
int i = Convert.ToInt32(c);
Console.WriteLine(i);
//int i = 66;
//char c =Convert.ToChar(i);
//Console.WriteLine("the value of c is: " + c);
Console.ReadLine();
}
}
}
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 unboxing
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
namespace whileloop
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}