如何HtmlHelper.AnonymousObjectToHtmlAttributes幕后工作? (方法调用自身) [英] How HtmlHelper.AnonymousObjectToHtmlAttributes works behind the scenes? (Method calls itself)

查看:178
本文介绍了如何HtmlHelper.AnonymousObjectToHtmlAttributes幕后工作? (方法调用自身)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了System.Web.Mvc.dll程序的ILSpy的反映,发现了以下code:

I did a reflection with ILSpy of System.Web.MVC.dll and found out the following code:

public static RouteValueDictionary AnonymousObjectToHtmlAttributes(object htmlAttributes)
    {
        return HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);
    }

有人可以帮助我了解究竟发生在这里?这应导致StackOverflow的例外,但没有。

Can someone help me to understand what exactly is happening here? This should lead to a StackOverflow Exception, but doesn't.

推荐答案

斯蒂芬Muecke上述评论,从System.Web.MVC.HtmlHelper方法AnonymousObjectToHtmlAttributes呼唤具有相同的名称,但是从System.Web.WebPages的方法。 Html.HtmlHelper。

As Stephen Muecke commented above, the method AnonymousObjectToHtmlAttributes from System.Web.MVC.HtmlHelper is calling a method with the same name but from System.Web.WebPages.Html.HtmlHelper.

该ILSpy没有明确这一点。我需要悬停类从哪里有人来显示:

The ILSpy is not explicitly about that. I needed to hover the class to show from where it was coming:

ILSpy

我不是第一个与<一个href=\"http://stackoverflow.com/questions/31370765/ilspy-a-k-a-net-reflector-shows-a-method-as-just-calling-itself-why\">doubt,它是被常犯的错误,我相信。

I'm not the first with that doubt, it's a common mistake to be made, I believe.

这篇关于如何HtmlHelper.AnonymousObjectToHtmlAttributes幕后工作? (方法调用自身)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆