blazor中可能有泛型类型约束吗? [英] Are generic type constraints possible in blazor?

查看:63
本文介绍了blazor中可能有泛型类型约束吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将TModel限制为仅类或实现特定接口?

How can I restrict TModel to be classes only or to be implementing a specifix interface?

@typeparam TModel

无法使用语法.

推荐答案

解决方案是另外将类型约束放在类后面的部分代码中.可行!

The solution is to additionally put the type constraint in a partial code behind class. It works!

这篇关于blazor中可能有泛型类型约束吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆