I am migrating my Blazor Server from .NET 7 to 8. Apparently it causes error on calling the function this way:
<code><input type="checkbox" class="form-check" checked="@isChecked" @onchange="@((e) => AddRemoveSelection((int)i.Id!, Convert.ToBoolean(e.Value)))" />
</code>
<code><input type="checkbox" class="form-check" checked="@isChecked" @onchange="@((e) => AddRemoveSelection((int)i.Id!, Convert.ToBoolean(e.Value)))" />
</code>
<input type="checkbox" class="form-check" checked="@isChecked" @onchange="@((e) => AddRemoveSelection((int)i.Id!, Convert.ToBoolean(e.Value)))" />
The compiler says “The delegate type could not be inferred” and highlighted “=>” arrow function with red underline.
Below is the method itself
<code>private void AddRemoveSelection(int id, bool isSelected)
{
if (isSelected)
{
//Adding ids to selection
if (!selectedIds.Any(s => s == id))
{
selectedIds.Add(id);
}
}
else
{
var s = selectedIds.Find(s => s == id);
selectedIds.Remove(s);
}
}
</code>
<code>private void AddRemoveSelection(int id, bool isSelected)
{
if (isSelected)
{
//Adding ids to selection
if (!selectedIds.Any(s => s == id))
{
selectedIds.Add(id);
}
}
else
{
var s = selectedIds.Find(s => s == id);
selectedIds.Remove(s);
}
}
</code>
private void AddRemoveSelection(int id, bool isSelected)
{
if (isSelected)
{
//Adding ids to selection
if (!selectedIds.Any(s => s == id))
{
selectedIds.Add(id);
}
}
else
{
var s = selectedIds.Find(s => s == id);
selectedIds.Remove(s);
}
}
Is there any new changes in Blazor 8 that disables this syntax?