เป็นโปรแกรมที่รับค่าส่งไปที่ CLASS แล้วส่งค่ากลับมาเพื่อแสดงผลต่อไป
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;
namespace Test_Class
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void outCustomerID_Click(object sender, EventArgs e)
{
}
private void outCustomerName_Click(object sender, EventArgs e)
{
}
private void outAddressIP_TextChanged(object sender, EventArgs e)
{
}
private void Submit_Click(object sender, EventArgs e)
{
ClassA c = new ClassA();
c.CustomerID = "A001";
c.CustomerName = "Bank";
c.AddressIP = "192.168.1.12";
outCustomerID.Text = c.CustomerID;
outCustomerName.Text = c.CustomerName;
outAddressIP.Text = c.AddressIP;
}
}
}
Code of classA
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test_Class
{
class ClassA
{
private string _CustomerID;
private string _CustomerName;
private string _AddressIP;
public string CustomerID
{
get
{
return _CustomerID;
}
set
{
_CustomerID = value;
}
}
public string CustomerName
{
get
{
return _CustomerName;
}
set
{
_CustomerName = value;
}
}
public string AddressIP
{
get
{
return _AddressIP;
}
set
{
_AddressIP = value;
}
}
}
}
สามารถดาวน์โหลดไฟล์ไปลองเล่นดูได้ครับ Test_Class.rar (113.1 KB)