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 are the advantages of clr procedure over t-sql procedure?
Why is ienumerable used?
Define parsing? Explain how to parse a datetime string?
How do I join one form to another in c#?
What is satellite assembly? And steps to create satellite assembly?
explain Garbage collector’s functionality on unmanaged code
What are get and set in c#?
What is dbcontext c#?
What are the classes contained in a single .NET DLL ?
Can you create sealed abstract class in c#?
What is the c# equivalent of c++ catch (…), which was a catch-all statement for any possible exception? Does c# support try-catch-finally blocks?
Why do we use constructors in c#?
What are desktop applications examples?
Can you specify an access modifier for an enumeration?
What do you mean by a windows process in regards to memory allocation?