كيف يمكنني استخدام .صافي الوراثة وراثة قالب المعلمة ؟

StackOverflow https://stackoverflow.com/questions/90117

  •  01-07-2019
  •  | 
  •  

سؤال

أريد أن تكون قادرة على القيام بذلك.

MyInterface interface = new ServiceProxyHelper<ProxyType>();

هنا بنية الكائن

MyTypeThatImplementsMyInterface : MyInterface

هل هذا العمل ؟

public class ProxyType : MyInterface {}

public class ServiceProxyHelper<ProxyType> : IDisposable, MyInterface {}
هل كانت مفيدة؟

المحلول

وأعتقد أن هذا هو ما كنت تحاول القيام به:

public class ServiceProxyHelper<T> where T : MyInterface { ... }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top