What is difference between Convert.ToString(variable) and
variable.ToString()

Answer Posted / abdul

Convert.ToString handles null where as simple
variable.ToString() doesn;t;

But Convert class is an optimization cost, when we use
inside any loop, need to minimize it

Sample ToString();

Will Work
int salary = 10000;
string oldSalary = salary.tostring();

Will Throw exeption
int salary = null;
string oldSalary = salary.tostring(); ---> throws exception

Sample Convert.ToString()
Will Work
int salary = 10000;
string oldSalary = Convert.ToString(salary);

Will Work
int salary = null;
string oldSalary = Convert.ToString(salary); null will return








Is This Answer Correct ?    13 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between malloc () and new?

495


Give examples for value types?

493


What is callback delegate in c#?

459


How do you sort an array in c#?

498


What is the main purpose of delegates in c#?

509






Is overriding of a function possible in the same class?

473


What is the value which is accepted by all data types ?

520


What is a derived class in c#?

479


What is difference between web and window application?

398


What is the difference between array and list in c#?

483


What do you use c# for?

490


Why do we use void in c#?

474


Is c# int immutable?

510


Can we change static value in c#?

530


What is difference between sleep () and wait ()?

492