C# 将属性设置为分部类中的方法
我有以下课程:C# 将属性设置为分部类中的方法,c#,attributes,partial,C#,Attributes,Partial,我有以下课程: public partial class A //file 1 { public int Sum(int a, int b) { return a+b; } } 如何将属性设置为类a的分部的Sum方法 public partial class A //file 2 { //Todo } 我使用了MetadataTypeAttribute,但只能设置为properties。问题是方法
public partial class A //file 1
{
public int Sum(int a, int b)
{
return a+b;
}
}
如何将属性设置为类a的分部的Sum方法
public partial class A //file 2
{
//Todo
}
我使用了MetadataTypeAttribute,但只能设置为properties。问题是方法!
请记住,我们不能修改文件1中的分部类您只能在声明方法的位置添加属性。因此,我们不能从其他分部类中设置它!