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
How to Show Message box in Metro Style App?
What is autopostback in c#?
What is a Jagged Array in C#?
How many variables do you need?
What is the difference between array and arraylist in c#?
What is callback delegate in c#?
Is there hashmap in c#?
What is Fragmentation and its Types?
What is ildasm and obfuscator in net?
Does a class need a constructor c#?
What is the difference between integer and double?
Define MSIL, and how does it works? Why our developers need an appreciation of it if at all?
Are c# constructors the same as c++ constructors?
How many types of inheritance are there in c#?
What happens during the process of boxing?