Hi Guys
NP145 as operator
It is said that as operator is used to perform conversions between compatible types.
Here what is meant by compatible types. In the following program Drived class is inherited from Base class therefore can we say both the Drived class and Base class are compatible. Is that the reason as has been used.
I wish to whether my understanding is correct.
Please confirm.
Thank you
using System;
class csrefKeywordsOperators
{
class Base
public override string ToString()
return "Base";
}
class Derived : Base
{ }
class Program
static void Main()
Derived d = new Derived();
Base b = d as Base;
if (b != null)
Console.WriteLine(b.ToString());
//Base