调用类方法作为参数

时间:2021-06-15 07:28:45

标签: c#

可以在 C# 上做这样的事情吗?我想要一个通用的 void 来从另一个类调用不同的方法。

public class custom{
   public void A(){}
   public void B(){}
}

void doSomething(List<custom> laux, method m ){
    foreach(var aux in laux){
        aux.m; //something like this
    }
}

void main(){
   doSomething(new List<custom>(),A);
   doSomething(new List<custom>(),B);
}

1 个答案:

答案 0 :(得分:8)

您可以通过 @Entity(tableName = "order_table") data class Order( val adress: String? = null, val clientName: String? = null, val clientUnicId: String? = null, val mobileNumber: String? = null, val note: String? = null, val orderDate: Date? = null, @PrimaryKey val orderId: Int, var status: Boolean? = null, val userId: Int? = null ) 委托执行一些接近的事情:

Action
相关问题