What is the Difference between directcast and ctype?

Answers were Sorted based on User's Feedback



What is the Difference between directcast and ctype?..

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

What is the Difference between directcast and ctype?..

Answer / narayan sahu(netx)

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

What is the Difference between directcast and ctype?..

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

Post New Answer

More Dot Net General Interview Questions

Can a dll be changed to an exe?

0 Answers  


How WSDL is stored ?

1 Answers   PPS, TCS,


Different levels of priority provided by .net.

0 Answers  


Compare & contrast rich client (smart clients or windows-based) & browser-based web application

0 Answers  


What is meant fulltrust?

1 Answers  






What are the advantages of .net core?

0 Answers  


If you are executing these statements in commandobject. Select * from table1; select * from table2? How you will deal result set? 42. How do you sort a dataset.

0 Answers  


What do you mean by Driver Script?

0 Answers   TCS,


Explain the features that are common to all .Net languages.

0 Answers   Accenture,


What does jit do?

0 Answers  


What is Complex Class in .NET?

0 Answers  


What is a .DLL and .EXE files called in .NET?

0 Answers   CitiusTech,


Categories