What is the Difference between directcast and ctype?
Answers were Sorted based on User's Feedback
Answer / aravindreddy
DirectCast requires the run-time type of an object variable
to bethe same
as the specified type.The run-time performance
ofDirectCast is better
than that of CType, if the specified type and the run-time
typeof the
expression are the same.
Ctype works fine if there is a valid conversion defined
between the
expression and the type.
| Is This Answer Correct ? | 16 Yes | 2 No |
The difference between the two keywords is that CType
succeeds as long as there is a valid conversion defined
between the expression and the type, whereas DirectCast
requires the run-time type of an object variable to be the
same as the specified type. If the specified type and the
run-time type of the expression are the same, however, the
run-time performance of DirectCast is better than that of
CType. DirectCast throws an InvalidCastException error if
the argument types do not match.
| Is This Answer Correct ? | 12 Yes | 3 No |
Answer / suresh
Direct cast: Supports only reference type conversions
it throws exception
CType cast: supports only Value type conversions
| Is This Answer Correct ? | 7 Yes | 22 No |
What is meant by .Net framework?
What is "common language specification" (cls) in .net?
How do you create threading in.net?
Explain what is the difference between web application and enterprise application?
Write an StoredProcedure to get the values of a column within a date range.
What is the use of UML in .Net
Tell us the difference between the while and for loop. Provide a .net syntax for both loops?
Which namespace does it belong to by default?
Can you edit data in repeater control? How?
I have a problem in installing visual Studio 2008 on PC that have Celeron Processor ? afterAll InstallionFaied . Pls suggest me . Is it possible or not .if Yes then How ?
How you apply a theme in whole application in .Net?
Explain Creational design pattern in .NET?