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 poco c#?
What can we do to handle multiple exceptions?
Is it possible to have different access modifiers on the get/set methods of a property?
What is token in c#?
Is php better than c#?
Why is it not a good idea to use empty destructors?
What is the use of getcommandlineargs() method in c#.net?
Which language is used for desktop application?
What is dapper in c#?
Can non-default constructors be used with single call sao?
What is the default value of date?
how to stored and retrive video in Sql server using asp.net c#......?
Can you explicitly call a destructor?
What is windows form in c#?
What are the properties of c#?