is there a override for when a given type is being instanced as an array?

Im wondering if i can inject some logic if a type is being instanced as an array. say a class A. is being instanced as array, i want inject a sorting algorithm without depending on the user to run a member function or have something like a factory for the object creation
3 Replies
Pobiega
Pobiega•11mo ago
Short answer: no. Long answer: Sounds like an X Y problem to be honest. You could create a ACollection class that wraps the array and provides the sorting for you, if its that important. Its also a bit weird in general. What if the consuming code doesnt care about sort order, or wants to use a specific order?
nightooi /s I'm rarely serious
I'd agree but in this case its a model for a view the viewmodel has some taghelpers that are dependent on a complex type in the composite model which I is a array... Okey im an idiot. I just need a constructor for the consumer and run the sorting in the constructor, good enough in this case. Thinking is hard when
Pobiega
Pobiega•11mo ago
🙂 If you are done, feel free to /close the thread.
Want results from more Discord servers?
Add your server