The code below was made using .Net 5.0.203
I've this component
MyComponent.razor
@typeparam TItem
<p>MyComponent: @typeName</p>
@code {
[Parameter]
public IEnumerable<TItem> Data { get; set; }
string typeName;
protected override void OnInitialized()
{
typeName = typeof(TItem).Name;
}
}
and here is the page calling the component
Index.razor
@page "/"
<MyComponent Data="@items"></MyComponent>
<p>Page: @itemsType</p>
@code
{
string[] items = new string[2];
string itemsType;
protected override void OnInitialized()
{
itemsType = items.GetType().Name;
}
}
I expected the type of TItem in MyComponent is String[] however it's String
How Blazor infer the type of TItem?