110,546
社区成员
发帖
与我相关
我的任务
分享
public void GetParams()
{
inItem.Clear();
this.GetElementInContainer((Control)HttpContext.Current.Handler, inItem);
}
public void GetParams(Control container)
{
inItem.Clear();
this.GetElementInContainer(container, inItem);
}
private ItemCollection GetElementInContainer(Control container, ItemCollection sc)
{
foreach (Control control in container.Controls)
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Test
{
public int ID { get; set; }
public string Name { get; set; }
public DateTime CreateTime { get; set; }
}
class Program
{
static void Main(string[] args)
{
Test t = new Test() { ID = 1, Name = "abc", CreateTime = DateTime.Now };
var query = t.GetType().GetProperties().Select(x => string.Format("{0}: {1}.", x.Name, x.GetValue(t, null).ToString()));
foreach (string prop in query)
{
Console.WriteLine(prop);
}
}
}
}
ID: 1.
Name: abc.
CreateTime: 2013-9-23 1:07:50.
Press any key to continue . . .