1.array:
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 ClassLibrary3;
namespace collectionarray
{
public partial class Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
Class1
[]arr = new Class1
[5];
int i =
0;
private
void button1_Click(object
sender, EventArgs e)
{
Class1
obj = new Class1();
obj.Id =int
.Parse (textBox1.Text);
obj.Name = textBox2.Text;
arr[i] = obj;
i++;
label4.Text = "saved";
}
private
void button2_Click(object
sender, EventArgs e)
{
Class1
obj = new Class1();
obj = arr[0];
textBox1.Text = (obj.Id).ToString
();
textBox2.Text =
(obj.Name).ToString ();
}
private
void button3_Click(object
sender, EventArgs e)
{
Class1
obj = new Class1();
int
a = i;
obj = arr[a-1];
textBox1.Text =
(obj.Id).ToString();
textBox2.Text =
(obj.Name).ToString();
}
private
void button4_Click(object
sender, EventArgs e)
{
Class1
obj = new Class1();
int
a=int.Parse (textBox3 .Text);
obj = arr[a - 1];
textBox1.Text =
(obj.Id).ToString();
textBox2.Text =
(obj.Name).ToString();
}
private
void textBox1_TextChanged(object sender, EventArgs
e)
{
label4.Text = "";
}
}
}
Classlibrary3:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ClassLibrary3
{
public class Class1
{
int id;
public int Id
{
get
{ return id; }
set
{ id = value; }
}
string
name;
public string Name
{
get
{ return name; }set { id = value; }}
Posted By:Tanuj Kumar
Comments
Post a Comment