Interviews - C# Corner

Atulya Panda
What is the use of "as" Keyword ?
By Atulya Panda in ASP.NET on Nov 26 2012
  • Ramakrishna
    Dec, 2012 4

    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 empEmployee emp1 = emp as Employee;Console.WriteLine(emp1.a);// emp2 would be nullvar emp2 = emp as Manager; } }

    • 0

Most Popular Companies

Most Popular Job Functions