What is the difference between DirectCast and CType ?
Interview question and answer by:
Bharathi Cherukuri | Posted on: 4/24/2012 | Category:
C# Interview questions | Views: 850 | |
Points: 40
Answer:
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
Found interesting? Add this to: