what is the diference between casting and converting?
Answers were Sorted based on User's Feedback
Answer / kiran vaidya
When you use Convert class, you have some predefined types
which are defined by .Net framework such as Convert.ToInt32
or Convert.ToString and so on. That means you can convert
whatever you want to only system defined types.
while in casting, you can have your own choices to convert
data. i.e. user defined types.
for eg. you have a class called Employee and you want to
convert some object to Employee, then the best way to do
this is casting.
| Is This Answer Correct ? | 10 Yes | 0 No |
Answer / praveen
The Convert.ToInt32(String, IFormatProvider) underneath
calls the Int32.Parse. So the only difference is that if a
null string is passed to Convert it returns 0, whereas
Int32.Parse throws an ArgumentNullException.
It is really a matter of choice whichever you use.
Also have a look at the new .NET 2.0 method Int32.TryParse,
which attempts to convert a string to an int without
throwing an exception.
| Is This Answer Correct ? | 8 Yes | 0 No |
What is serialization in .net?
In c#.Net Application For DataGridview binding which method is faster in below two case?Why..? 1)looping-Using For loop 2)Databinding direct using Dataset
what is be the overhead, if i use binary transmission. and will it be sent using xml text or how ?
What are extender provider components?
What is the difference between continue and break statement?
Why does my windows application pop up a console window every time I run it?
What is the difference between func and action delegate?
why C#.net doesnot support prcedures and why it supports structs,functions
Define clr in .net?
What is the use of flag in c#?
How is a loop recorder monitored?
What floating point types is supported 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)