C
C#13mo 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
HtmlCompiler
HtmlCompiler13mo ago
$itdepends
HtmlCompiler
HtmlCompiler13mo ago
it's not a priori choice
eid
eidOP13mo 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)
HtmlCompiler
HtmlCompiler13mo ago
it's kinda difficult to understand you, can you make an example with code?
lycian
lycian13mo 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?
Want results from more Discord servers?
Add your server