More fluent C# / .NET

后端 未结 21 1285
名媛妹妹
名媛妹妹 2020-12-23 22:51

A co-worker of mine came up with this and I wonder what others think? Personally, I find it interesting but wonder if it is too big a departure? Code examples below. Extensi

21条回答
  •  -上瘾入骨i
    2020-12-23 23:40

    The original is more readable.

    The simplest API change would be to make the object returned by FindControl() a Builder-esque thing (where all the set methods return 'this'):

    Page.FindControl("LocationDropDownList")
        .setVisible(true)
        .setSelectedValue(isAdmin ? "111" : "123");
    

提交回复
热议问题