Tôi có một câu hỏi liên quan đến các cuộc gọi phương pháp sau đây:Generic đường cú pháp hoặc cải thiện đúng
var ctl1 = this.FindControlRecursively("SomeField") as HiddenField;
var ctl = this.FindControlRecursively<HiddenField>("SomeField");
Dưới đây là IL cho hai cuộc gọi sau đây:
IL_0010: ldstr "AsyncReset"
IL_0015: call class [System.Web]System.Web.UI.Control [Amc.WebG081.MethodExtensions]Amc.WebG081.ControlExtensions::FindControlRecursively(class [System.Web]System.Web.UI.Control,string)
IL_001a: isinst [System.Web]System.Web.UI.WebControls.HiddenField
IL_001f: stloc.0
IL_0020: ldarg.0
IL_0021: ldstr "AsyncReset"
IL_0026: call !!0 [Amc.WebG081.MethodExtensions]Amc.WebG081.ControlExtensions::FindControlRecursively<class [System.Web]System.Web.UI.WebControls.HiddenField>(class [System.Web]System.Web.UI.Control,string)
Tôi đã luôn luôn nghĩ rằng trong tình huống này, phiên bản chung của phương pháp này là nhiều hơn "cú pháp đường" so với cải tiến thực sự. IL có kể một câu chuyện khác không?