I have a general method
public static void DoSomething<T>()
{...}
. Now I want to limit T.
public static void DoSomething<T>() where T: IInterface1
{...}
But I really want some interfaces, something like
public static void DoSomething<T>() where T: IInterface1, IInterface2
{...}
But that does not work. The compiler says something like
There is no implicit conversion from IInterface1 to IInterface2
There is no implicit conversion from IInterface2 to IInterface1
I thought about letting classes implement a common interface that I can access, but I don't have access to classes.
What features can I enable for multiple interfaces?
Thanks Tobi
Edit: This is what I wanted to do. I am developing Outlook-Add-In. I often use this piece of code.
public static object GetItemMAPIProperty<T>(AddinExpress.MAPI.ADXMAPIStoreAccessor adxmapiStoreAccessor, object outlookItem, uint property) where T: Outlook.MailItem, Outlook.JournalItem
{
AddinExpress.MAPI.MapiItem mapiItem;
mapiItem = adxmapiStoreAccessor.GetMapiItem(((T)outlookItem));
return mapiItem != null ? mapiItem.GetProperty(property) : null;
}
GetMapiItem , Outlook (, , ,...). T. , , Outlook.MAPIFolder.
.
public static object GetItemMAPIProperty<T>(AddinExpress.MAPI.ADXMAPIStoreAccessor adxmapiStoreAccessor, T outlookItem, uint property)
{
AddinExpress.MAPI.MapiItem mapiItem;
mapiItem = adxmapiStoreAccessor.GetMapiItem(((T)outlookItem));
return mapiItem.GetProperty(property);
}
( I) , GetMapiItem . , . , , , ( OR) .