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
$itdepends
it's not a priori choice
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)
it's kinda difficult to understand you, can you make an example with code?
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?