如果我需要做这样的事情:
var connection = new Connection(host);
connection.Execute(Commands.Delete);
这样做有什么问题吗:
(new Connection(host)).Execute(Commands.Delete);
第一个示例可能更具可读性,但如果我需要多次执行此操作,则第二个示例效果更好:
(new Connection(anotherHost)).Execute(Commands.Create);
(new Connection(someOtherHost)).Execute(Commands.Update);
(new Connection(host)).Execute(Commands.Delete);