Atulya Panda
What is the use of "as" Keyword ?
Posted by Atulya Panda in .Net | ASP.NET on Nov 26, 2012
  • 0
  • 1
  • 663
Do you know the answer for this question? Post it below.
Guest
Posted by Ramakrishna on Dec 04, 2012
  • 0

As operator allows you to perform conversions between compatible reference types. Consider the following example... using System; class Employee { public int a = 10; } class Manager : Employee { } class Program { static void Main(string[] args) { Employee emp = new Employee(); // emp1 would point to the same object as emp Employee emp1 = emp as Employee; Console.WriteLine(emp1.a); // emp2 would be null var emp2 = emp as Manager; } }


Nevron Chart
SPONSORED BY
Nevron Diagram
PRIVACY POLICY | TERMS & CONDITIONS | SITEMAP | CONTACT US | ABOUT US | REPORT ABUSE
2013© C# Corner. All contents are copyright of their authors.