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 static constructor, when it will be fired?
How we can achieve Connection pooling in .Net?
What is Ajax? How it is related to your project?
What is delegation in .net?
What is the difference between Server.Transfer and Response.Redirect?
What base class do all Web Forms inherit from?
What's the .net collection class that allows an element to be accessed using a unique key?
What security mechanisms to enforce for Authenticating and authorizing the users?
How many languages .NET is supporting now?
38 Answers Dreamtech, IBS, Microsoft, Polaris, RDT, Softcon, Viscus Infotech,
If any body working in Infosys, please can u give me the referense to that company because i hered that their is openings for freshers with referal..
Explain me what is the difference between a class and an object, and how do these terms relate to each other?
Explain can 2 different applications use the same dll in gac at the same time?