Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


directcast(123.34,integer) - should it throw an error? Why
or why not?

Answers were Sorted based on User's Feedback



directcast(123.34,integer) - should it throw an error? Why or why not? ..

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

directcast(123.34,integer) - should it throw an error? Why or why not? ..

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

Post New Answer

More C Sharp Interview Questions

What is the difference between dispose() and finalize() methods in c#?

0 Answers  


What is the use of command builder?

0 Answers  


What is an Interface in C#?

0 Answers   TryTechnicals Pvt Ltd,


What is difference between c sharp and c#?

0 Answers  


Does c# support parameterized properties?

0 Answers  


How many dimensions can an array have?

0 Answers  


What does the term immutable mean?

3 Answers   Satyam, Siebel Systems, Techno Labs,


how encapsulation is implemented in c#

0 Answers   Cognizant,


What is master page in asp net c#?

0 Answers  


If casting fails what type of exception is thrown?

0 Answers  


Can I define a type that is an alias of another type (like typedef in c++)?

0 Answers  


Are c# strings null terminated?

0 Answers  


Categories