开发者

Get Details of a Method in C#

In C# we can get all the details of a method using the following co开发者_运维问答de

XmlDocument doc = new XmlDocument();

Type t = doc.GetType();

System.Reflection.MethodInfo[] methods = t.GetMethods();

Here I am not able to get the comments of a method and the exceptions available in the method.


Comments are stripped at compile time and not part of the runtime metadata.

As for exceptions, any exception can be thrown from any method. Whereas exceptions in a sense are part of the interface of a method, they are not declared and are therefore not part of the runtime metadata either.

Hope this helps.


What do you mean by the exceptions available? Unlike Java, in .Net a method does not declare the exceptions that it can throw.


You cannot get a list of Exceptions that the method can throw, and comments are removed by the compiler.


There is no way to get the comments that are declared on a method like this, because they are not part of the assembly. You can't get the exceptions either, because in C# methods don't declare which exceptions the can throw.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜