多个泛型如何设置约束

提问

多个泛型如何设置约束

回答

public abstract class HandleBase<Req,Ack> where Req:RequestInfoBase where Ack : AckInfoBase

补充

泛型优点
避免类型转换,可以减少大量继承关系中的as 操作

posted @ 2023-09-21 14:19  东百牧码人  阅读(12)  评论(0)    收藏  举报