更新时间:2023-11-09 11:55:58
在链式中,您将返回在下一次调用中使用的方法调用的结果.
Chaining is where you return the result of the method call to be used in the next call.
c#
Enumerable.Range(0,10).Skip(1).Aggregate(myList.First(),(result,listItem) => result += listItem));
//results in 45 being returned
当返回this
时,可以通过使用链接来实现级联(有时很难区分两者). jQuery做到了.
Cascading can be implemented by using chaining when this
is returned (making it sometimes tricky to differentiate between the two). jQuery does this.
jquery
$("#myId").css("background-color","blue").fadeIn().fadeOut();
//results in $("#myId") being returned