C# Blazor: How to use @typeparam in Code behind? (with workaround)
问题 In a Blazor .razor file you can use @typeparam MyType to use generic parameters . For example: MyComponent.razor @typeparam MyType <SomeHtml /> @code { [Parameter] public List<MyType> MyList{ get; set; } } So you can call: <MyComponent MyType="MyTypeABC" MyList="@MyData.MyList" /> But I prefer code behind (razor.cs), how can I use a parameter for type like @typeparam MyType in the razor.cs file? My current workaround is: MyComponent.razor @inherits MyComponentCode<MyType> @typeparam MyType