© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
17 replies
Thinker

Calling a static abstract method without a generic type [Answered]

If I have this code with a static abstract member
Bar
Bar
in the interface
IFoo
IFoo
, is there any way (besides reflection) to call
Bar
Bar
on an instance of
IFoo
IFoo
without the explicit type of the instance?
IFoo f = GetFoo();
f.Bar(); // ???

static IFoo GetFoo() =>
  new Foo();

interface IFoo {
  static abstract void Bar();
}
class Foo : IFoo {
  public static void Bar() =>
    Console.WriteLine("bar");
}
IFoo f = GetFoo();
f.Bar(); // ???

static IFoo GetFoo() =>
  new Foo();

interface IFoo {
  static abstract void Bar();
}
class Foo : IFoo {
  public static void Bar() =>
    Console.WriteLine("bar");
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Ommit generic for static abstract conversion methods
C#CC# / help
9mo ago
Calling static method of interface via it's type
C#CC# / help
16mo ago