使用 C# 将 methodInfo.IsDefined() 设置为 true
我有来自示例类的 mymethod 方法的 methodInfo 。
internal class Example
{
public static void mymethod(string str1, ref string str2, out string str3)
{
....
MethodInfo mm = typeof(Example).GetMethod("mymethod");
如何使 mm 的属性(例如 ABCAttribute)
mm.IsDefined(typeof(ABCAttribute), true)
变为 true?
I have a methodInfo from mymethod method of Example class.
internal class Example
{
public static void mymethod(string str1, ref string str2, out string str3)
{
....
MethodInfo mm = typeof(Example).GetMethod("mymethod");
How can I make an attribute (for example, ABCAttribute) of mm so that
mm.IsDefined(typeof(ABCAttribute), true)
becomes true?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要定义您的属性。
然后将其应用到您的方法中。
You need to define your attribute.
Then apply it to your method.