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 |
What is the difference between dispose() and finalize() methods in c#?
What is the use of command builder?
What is an Interface in C#?
0 Answers TryTechnicals Pvt Ltd,
What is difference between c sharp and c#?
Does c# support parameterized properties?
How many dimensions can an array have?
What does the term immutable mean?
3 Answers Satyam, Siebel Systems, Techno Labs,
how encapsulation is implemented in c#
What is master page in asp net c#?
If casting fails what type of exception is thrown?
Can I define a type that is an alias of another type (like typedef in c++)?
Are c# strings null terminated?
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)