I have little peace of code:
private static void Casting<T>(T obj)
{
String str = (String)obj; //Error
str = obj as String;
}
Line String str = (String)obj
returns me compile-time error
"Error CS0030 Cannot convert type 'T' to 'string'"
Lets say, I agree with the error. But why second line do not same behavior? So my question is - why "as" do not generate the error, while casting do?