C
C#7mo 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
ffmpeg -i me -f null -
$itdepends
ffmpeg -i me -f null -
it's not a priori choice
eid
eid7mo 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)
ffmpeg -i me -f null -
it's kinda difficult to understand you, can you make an example with code?
lycian
lycian7mo 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?