我有一个类如何实现Action委托?
public class TextBoxConfig
{
public string Caption { get; set; }
public string FieldName { get; set; }
public int Width { get; set; }
public string Name { get; set; }
}
和另一工具类,其具有接受TextBoxConfig作为这样
public class Util
{
public static TextBox ApplySettings(TextBoxConfig config)
{
//Doing something
}
}
一般来说,我可以调用的Util类ApplySettings方法这样
的参数的方法TextBoxConfig config = new TextBoxConfig();
config.Caption = "Name";
config.FieldName = "UserName"
config.Width = 20;
config.Name = "txtName";
TextBox txt = Util.ApplySettings(config);
但我想将参数传递给ApplySettings像这样
TextBox txt = Util.ApplySettings(o =>
{
o.Caption = "Name";
o.FieldName = "UserName"
o.Width = 20;
o.Name = "txtName";
});
请建议我我该怎么办呢..
+1:回答这个问题(不管它听起来多么荒谬; p) – leppie
很好......谢谢Das :) –