C
C#14mo ago
eid

interface vs extension method vs method in class

what is better? to have a method directly in type or make the type implement it from interface or make the type have it by extension method?
6 Replies
FestivalDelGelato
$itdepends
FestivalDelGelato
it's not a priori choice
eid
eidOP14mo ago
i know when to use interface, extension method,and the member method. i mean if i have method it's name is map like select, i want type to have it(i can edit type),(i don't need to make the type interchangeably or use it in polymorphism) i make map as a member method in it, or as extenion method, or interface only i need any type that has map to be mapable, mean(has method map)
FestivalDelGelato
it's kinda difficult to understand you, can you make an example with code?
lycian
lycian14mo ago
only i need any type that has map to be mapable, mean(has method map)
So you're saying you don't know if the type has Map or not at compile time?

Did you find this page helpful?