I want a generic function that would work with types that have Top
, Bottom
, Right
and Rect
read-only properties - I have
You have to specify the base class that supports .Left in the where clause or you have to cast what to a type that supports the .Left-property:
internal class MyTemplate where WhatType : YourBaseClassWithLeftProperty
or
internal class MyTemplate {
internal static void Work( WhatType what ) {
YourBaseClassWithLeftProperty yourInstance=what as YourBaseClassWithLeftProperty;
if(null != yourInstance){
int left = yourInstance.Left;
}
}
...