Skip to content

Razor components: Calling method with optional argument from event - "Error CS1503: Argument 2: cannot convert from 'method group' to 'EventCallback'" #9542

@ChristianWeyer

Description

@ChristianWeyer

I have a function in my component like this:
private async Task LoadConferencesAsync(SearchFilter filter = null)

When I try to call it from an e.g. onclick event like this
<MudIcon Icon="@Icons.Material.Filled.Refresh" @onclick="LoadConferencesAsync" />

I get this error:
TTConfTool.UI/Conferences/Conferences.razor(66,66): Error CS1503: Argument 2: cannot convert from 'method group' to 'EventCallback' (CS1503) (TTConfTool.UI)

Screen Shot 2021-03-06 at 17 34 53

Should it be possible to call methods with optional parameters?

Thanks!


.NET SDK (reflecting any global.json):
Version: 6.0.100-preview.1.21103.13
Commit: b8a03527b2

Runtime Environment:
OS Name: Mac OS X
OS Version: 11.2
OS Platform: Darwin
RID: osx.11.0-x64
Base Path: /usr/local/share/dotnet/sdk/6.0.100-preview.1.21103.13/

Host (useful for support):
Version: 6.0.0-preview.1.21102.12
Commit: 9b2776d481

I am using Visual Studio Enterprise 2019 for Mac (Preview)
Version 8.10 Preview (8.10 build 409)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-compilerUmbrella for all compiler issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions