Static Vs delegates? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Static Vs delegates?

i know both r different...But i want to which one i should use? I have a method in another class which is static...i want to should i keep it static Or should i use delegates? which one will take more memory?

3rd Feb 2018, 6:10 PM
Somnath Ghosh
Somnath Ghosh - avatar
2 Answers
0
You shouldn't be concerned about memory for this. (But the delegate will take up a tiny amount more, as it's a pointer to the function that will exist either way.) As for which one you should use, I can't tell you. That's your decision and it depends on what your needs are for the program. Would you be passing the delegates around a lot because the function needs to be visible to many classes? You should probably choose a static function then. Will you need to dynamically change which function is called for any reason? You should probably choose a delegate. Both? You may want to have a static function that calls the delegate in the background. Good luck
4th Feb 2018, 4:02 AM
Jesse Bayliss
Jesse Bayliss - avatar
0
great,,thanks
6th Feb 2018, 6:02 PM
Somnath Ghosh
Somnath Ghosh - avatar