What is the difference between DirectCast and CType ?

 Posted by Bharathi Cherukuri on 4/24/2012 | Category: C# Interview questions | Views: 2824 | Points: 40

DirectCast requires the object variable to be the same in both the run-time type and the specified type.
If the specified type and the run-time type of the expression are the same, then the run-time performance of DirectCast is better than that of CType.
Ctype works fine if there is a valid conversion defined between the expression and the type.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response