When I try to build a Blazor component I can define parameters for it like this:
@code { [Parameter] public string MyString { get; set; }}My question is can I make this parameter required so that, when component is used, the project will not build unless I provide the specified parameter? Is this something I should even be worried about? I suppose I could handle any invalid values in component initialization by maybe throwing an exception if the value is not provided like this:
protected override void OnInitialized(){ base.OnInitialized(); if (string.IsNullOrWhiteSpace(MyString)) { // throw an exception here... }}but is that the right way to handle this?