C
C#16mo ago
Binto86

✅ Can't have interface with abstract static method as parameter in blazor component

I have interface and class like this:
interface IFoo
{
static abstract IFoo Create();
void SomeFunction();
}

class Foo : IFoo
{
public static IFoo Create() => new Foo();
public void SomeFunction() { }
}
interface IFoo
{
static abstract IFoo Create();
void SomeFunction();
}

class Foo : IFoo
{
public static IFoo Create() => new Foo();
public void SomeFunction() { }
}
now i want to have IFoo as parameter in blazor component like this:
[Parameter]
public IFoo MyFoo { get; set; }
[Parameter]
public IFoo MyFoo { get; set; }
but when i try to pass instance of Foo into the component i get this error: CS8920 The interface 'IFoo' cannot be used as type argument. Static member 'IFoo.Create()' does not have a most specific implementation in the interface. Any way to fix this?
1 Reply
Binto86
Binto86OP16mo ago
sure
<MyComponent MyFoo="foo"/>
<MyComponent MyFoo="foo"/>
oook i see looks like i will have to figure something out thanks for your help
Want results from more Discord servers?
Add your server