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 strong name assembly?
Explain the difference between Response.Write () and Response.Output.Write ().
For read-only operation which property you have to designated?
How can I produce an assembly?
Explain the difference between object type and dynamic type variables in c#?
Why does dllimport not work for me?
Explain the use of SN.exe
What is inumerable?
Explain About Assembly in .NET, types of assemblies, their difference, How to register into GAC. How to generate the strong names & its use.
What is dependency in software?
What is the purpose of namespace?
Can arraylist store different data types in c#?
How would you describe encapsulation in c#?
What is c# and why it is used for?
What is _layout cshtml?