在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
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 System.Dynamic; namespace WindowsFormsTest { public partial class dynamic类 : Form { public dynamic类() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { dynamic a = GetData(this.textBox1.Text); dynamic o = new ExpandoObject(); o.Id = a.Id; o.Title = a.Title; o.Time = DateTime.Now; MessageBox.Show(o); } private static dynamic GetData(string a) { if (a == "0") { News n = new News(); n.Id = 1; n.Title = "测试新闻"; return n; } else { Product p = new Product(); p.Id = 123; p.Title = "测试产品"; return p; } } } }
|
请发表评论