653

effective C# sau ...

.. sa-i ia naiba pe cei de la MS ca nu pricep nica..iaca mo impis pacatu si m-am apucat sacitesc literatura artistica:"Effective C#: 50 Specific Ways to Improve Your C# By Bill Wagner " ITEM 3 din manual zice: Prefer the is or as Operators to Castsadica in loc de object o = Factory.GetObject( );// Version one:MyType t = o as MyType;if ( t != null ){ // work with t, it's a MyType.} else{ // report the failure.}Or, you could write this:object o = Factory.GetObject( );// Version two:try { MyType t; t = ( MyType ) o; if ( t != null ) { // work with T, it's a MyType. } else { // Report a null reference failure. }} catch{ // report the conversion failure.}l aMS pe site : http://msdn2.microsoft.com/en-us/library/ms972962.aspx"//Cast this to an IPlugin interface and add to the collection IPlugin plugin = (IPlugin)plugObject;"de ce MS inca foloseste CAST .. cind .NEt are asa o fisca advanced.:)
0