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
Describe the process of “exception handling implementation” in c#?
What is a console operator?
What is view model in c#?
What is a lambda expression in c#?
What is the advantage of constructor in c#?
What is the use of console readline () in c#?
How many keyword present in C# language ?
How do I simulate optional parameters to com calls?
What is the advantage of singleton class?
What are accessors?
Can we overload indexer in c#?
What does protected internal access modifier mean?
Is java better than c#?
Why do we use hashtable in c#?
What is the difference between an integer and int?