directcast(123.34,integer) - should it throw an error? Why
or why not?
Answers were Sorted based on User's Feedback
Answer / debasis sengupta
directcast(123.34,integer) would throw an InvalidCast
exception since it requires the runtime type of the object
variable to be same as the specified type. In this case
runtime type of 123.34 (double) doesn?t match with integer.
but for ctype(123.34,integer) - it would work fine. As the
runtime type of 123.34 would be double, and Double can be
converted to Integer.
| Is This Answer Correct ? | 6 Yes | 0 No |
Answer / debasis sengupta
directcast(123.34,integer) would throw an InvalidCast
exception as the runtime type since it requires the run-
time type of an object variable to be same as the specified
type. In this case runtime type of 123.34 (double) doesn?t
match with integer.
| Is This Answer Correct ? | 1 Yes | 1 No |
List some Advantages of switch-case over if else?
What are the classes contained in a single .NET DLL ?
How long has c# been around?
Can a class or a struct have multiple constructors?
Distinguish between array and arraylist in c#?
What is a dictionary in c#?
What is Dispose method in .NET ?
9 Answers 247Customer, KAP, TCS,
Is dictionary reference type c#?
Explain how do you convert a value-type to a reference-type?
How do I create a .exe file?
Is lazy thread safe c#?
Why do we need ienumerable in c#?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)