Current .Net Version: 1.1.4322
Home
Articles
Practice C# Online
C# Reference
XML Web Services
RSS Feeds
T-SQL Scripts
Videos
Valuable Links
Contact Us
Mike's C#, VS.NET and SQL Blog
ROR XML Info.
C# Reference
The world's largest C# Language & Framework Class Library Reference Database (second only to Microsoft's)!
Language Reference:
Language Search:
Framework Class Library Reference:
Framework Class Library Search:

as
Is a:Operator Keyword
Applies to Version:C# 1.0 and later
Namespace:N/A
Assembly:N/A (N/A)
Description:Converts a type to a complatible type. Basically, as performs explicit casting. as converts reference types only.
Syntax:
expression as type;
(expression as type);
MSDN:http://msdn.microsoft.com/library/en-us/csref/html/vclrfAs.asp?frame=true
Example(s):DateTime dt = DateTime.Now; Object dtObject = dt as DateTime; // this will throw an exception - value type Exception ex = new Exception(); Object exObject = ex as Exception; // this will work - reference type // The preceding statement is the same as this: Object exObject2 = (Exception) ex;
 
COPYRIGHT/DISCLAIMER | CONTACT US