سؤال

Is it considered 'good practice' to re-use objects in c#.
For example:
      Say you have a class called Anima and create an oject of type animal called monkey:

Animal monkey = new Animal(paramA);
monkey = new Animal(paramB);
هل كانت مفيدة؟

المحلول

Yep, that sound about right. The previous instance you now lose reference to should be caught up in the next Garbage Collection cycle.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top