Wenn Sie eine Klasse ( z. B. eine Auflistung ) entwerfen, die jeden Objekttyp behandeln muss, können Sie Klassenmember erstellen, die Instanzen der Object-Klasse akzeptieren.
Das Boxing und Unboxing von Typen ist jedoch leistungsintensiv.
Wenn Sie wissen, dass die neue Klasse häufig bestimmte Werttypen behandeln wird, können Sie eines von zwei Verfahren zur Minimierung des Kostenaufwands für Boxing anwenden.
msdn.microsoft.comIf you are designing a class, such as a collection, that must handle any type of object, you can create class members that accept instances of the Object class.
However, the process of boxing and unboxing a type carries a performance cost.
If you know your new class will frequently handle certain value types you can use one of two tactics to minimize the cost of boxing.
msdn.microsoft.comИскаш ли да добавиш дума, фраза или превод?
Изпратете ни нов запис.