What is difference between Convert.ToString(variable) and
variable.ToString()

Answer Posted / pavel

object ss =null;

string s1 = ss.ToString(); ---------- exeption
string s2 = Convert.ToString(ss); --- ""

--------------------
int ss =null; --- int can't be converted to null

--------------------
int ss = 1;

string s1 = ss.ToString(); ---------- "1"
string s2 = Convert.ToString(ss); --- "1"

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a c# delegate?

607


How do you name a variable in c#?

509


Why do we need generics?

519


Is c# an array?

480


What is local function?

524






What are controls in c#?

480


How to find methods of a assembly file (not using ILDASM)?

645


What exception can an overridden method throw in comparison with the method it is overriding?

465


If I have more than one version of one assemblies, then how'll I use old version (how/where to specify version number?)in my application?

528


Are constructors inherited c#?

515


Can hashset contain duplicates c#?

468


What is polymorphism and its types in c#?

459


What's the difference between abstraction and encapsulation?

467


How many parameters can a method have c#?

487


What is byte c#?

449