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 a console application in c#?
Why do we need delegates in c#?
What are the Types of values mode can hold session state in web.config
Can multiple inheritance implemented in c# ?
What are the 2 broad classifications of fields in c#?
What is jagged array?
What are the differences between static, public and void in c#?
What are the two uses of a ‘using’ statement in c#?
Is array thread safe c#?
How can I use .NET components from COM programs?
Explain the accessibility modifier protected internal?
Why do I get a syntax error when trying to declare a variable called checked?
What does == mean in c sharp?
List some of the basic string operation?
What is a static class in c#?