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
What is the difference between malloc () and new?
Give examples for value types?
What is callback delegate in c#?
How do you sort an array in c#?
What is the main purpose of delegates in c#?
Is overriding of a function possible in the same class?
What is the value which is accepted by all data types ?
What is a derived class in c#?
What is difference between web and window application?
What is the difference between array and list in c#?
What do you use c# for?
Why do we use void in c#?
Is c# int immutable?
Can we change static value in c#?
What is difference between sleep () and wait ()?