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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Person person = new Person();
label1.Text=person.Info;
person.Name = "Joe";
person.Age = 18;
label2.Text=person.Info;
person.Age += 1;
label3.Text=person.Info;
}
}
class Person{
private string myName="N/A";
private int myAge= 0;
public const int C = 10;
public readonly int D = 10;
public string Name{
get{
return myName;
}
set{
myName = value;}
}
public int Age{
get{
return myAge;
}
set{
myAge= value;
}
}
public string Info{
get{
return "Name:"+Name+",Age"+Age;
}
}
}
}
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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Address address = new Address();
label4.Text = address.getMessage;
}
class Address {
private string name;
private string tel;
private string ema;
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
public string getMessage
{
get
{
return "姓名:" + name + ",电话号码" + tel+",Email"+ema;
}
}
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/4926.html