クラスがあります
public class TextBoxConfig
{
public string Caption { get; set; }
public string FieldName { get; set; }
public int Width { get; set; }
public string Name { get; set; }
}
そして、このようなパラメーターとして TextBoxConfig を受け入れる Method を持つもう 1 つのユーティリティ クラス
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";
});
どうすればいいのか教えてください..