I was curious to know the difference between using a keyword as, casting, or using a function Convert.To_______().
as
Convert.To_______()
After a short search, I found that the operator asonly performs link conversions and box transforms. What other differences exist.
I also noticed that the keyword is asvery rarely used, why this is so. Any of them has a performance advantage over others or just redundancy in the Framework.
(cast) :
"as"
, test - , . , :
// is it a list? IList list = obj as IList if(list != null) { // specific code for lists }
, , (), . ( ) .
Convert , ( , static. Parsse methods)
, Convert, . (cast) "as" .
casting vs as: casting throws in exception, null, . .
: . , . , Convert.
% 100 , , , , Convert,
.
Source: https://habr.com/ru/post/1782254/More articles:GWT serialization and Api add channel - javaCleaning up WinAPI controls - c ++Rails - how to update a single attribute in a controller - ruby-on-railsBluetooth in Java Mobile: Handling Connections Out of Range - javaScrollPane прокручивает до нижней части - javaScrolling JScrollPane with last line added - javadisable selection of menustrip by pressing alt - .netHow to Open Outlook New Mail Message Window from VB.NET - .netfunction caller name in anonymous function - javascriptКак я могу сделать поток "report back" в основной поток? - multithreadingAll Articles