Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6080577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:04:39+00:00 2026-05-23T11:04:39+00:00

I want to have a generic parameter which implement certain static function. As a

  • 0

I want to have a generic parameter which implement certain static function. As a part of its interface(teh static function) for me it is logical to have such generic parameter constrain, but I cannot find how to do this. Any help is appreciated.

Currently I’m fixing such problems by defining NOT static properties which returns static values, which as OOP developer I certainly don’t like. This properties are part of some interface and the generic param is constraint to inherit from the interface.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:04:39+00:00Added an answer on May 23, 2026 at 11:04 am

    You can’t – there’s no such thing as constraining a type parameter by static members, unless you count the new() constraint which requires a parameterless constructor.

    Note that static members can’t be part of an interface in the normal C# sense of the word – even though they can obviously be part of the public API of the type.

    I’ve previously blogged about the possibility of “static interfaces” in a future version of C# (just as a sort of feature request) but it’s definitely not available now.

    Sometimes the best alternative is to have a separate type implementing a normal interface – if you can give us more information about your context, we may be able to suggest alternative approaches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a generic function for a few types such as long,
I have a generic JavaScript function which takes one parameter function foo(val) { ...}
I want to have a generic object that implements an interface. I mean if
Lets say we have a program which contains such classes: public interface AbstractItem {
I have a trait, which takes a type parameter, and I want to say
I want to have a generic event that I can fire that will take
What would I do if I want to have a generic method that only
I want to write in Delphi (2009 - so I have generic dictionary class)
I have a generic class, but I want my type to be forced to
I have a generic Repository<T> class I want to use with an ObjectDataSource. Repository<T>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.