From: "Alex" <a.agranov@verizon.net>
Subject: Advantage of "as" operator over casting
Date: Sat, 2 Aug 2003 16:05:27 -0700
Lines: 5
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <uyjfRqUWDHA.3404@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: evrtwa1-ar14-4-42-093-032.evrtwa1.dsl-verizon.net 4.42.93.32
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:173771
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
Is that "as" returns null if failed to cast, doesn't throw an exception, so
you can check the reference for null afterwards. straight casting will throw
an InvalidCastException exception.