/BlazorPartialConstraint

Demonstrate Generic Component with Type Constraint

Primary LanguageHTML

Sample project demonstrates a constraint on a generic component

Please look at ConstrainedComponent in the Shared folder and its usage in Index.razor.

The compiler may not infer the type so you can specify the type as demonstrated here

<ConstrainedComponent SomeThing="Dummy" TItem="DateTime"></ConstrainedComponent>

Note: TItem="DateTime" tells the compiler that your generic type is a DateTime.