Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Difference between String.Convert Vs String.ToString

This is a discussion on Difference between String.Convert Vs String.ToString within the C# forums, part of the Software Development category; Hi Please explain the Difference between Convert Vs String.ToString...

Go Back   Geeks Talk > Software Development > C#
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 02-22-2007
Junior Member
 
Join Date: Feb 2007
Location: Bangalore
Posts: 17
Thanks: 0
Thanked 2 Times in 2 Posts
jbanx is on a distinguished road
Difference between String.Convert Vs String.ToString

Hi

Please explain the Difference between Convert Vs String.ToString

Last edited by jbanx; 02-22-2007 at 02:12 AM.
Reply With Quote
The Following User Says Thank You to jbanx For This Useful Post:
Sponsored Links
  #2 (permalink)  
Old 06-05-2007
Contributing Member
 
Join Date: May 2007
Location: bangalore
Posts: 65
Thanks: 3
Thanked 10 Times in 6 Posts
hari.nattuva is on a distinguished road
Re: Difference between String.Convert Vs String.ToString

Hi,

Diffrence between string.convert vs string.tostring is here tostring doesnot handle null values where as covert handle null values.

Regards,
hari prasad
Reply With Quote
The Following 2 Users Say Thank You to hari.nattuva For This Useful Post:
  #3 (permalink)  
Old 06-06-2007
Junior Member
 
Join Date: Feb 2007
Location: Bangalore
Posts: 17
Thanks: 0
Thanked 2 Times in 2 Posts
jbanx is on a distinguished road
Re: Difference between String.Convert Vs String.ToString

To tell you more Convert internally uses toString. In convert first there is a check for null, if there is null then string.empty is returned, else normal toString method is called
Reply With Quote
  #4 (permalink)  
Old 12-18-2007
Contributing Member
 
Join Date: Nov 2007
Location: bangalore
Posts: 54
Thanks: 6
Thanked 6 Times in 4 Posts
rahulvegi is on a distinguished road
Re: Difference between String.Convert Vs String.ToString

String.Convert:
convert the string from one to another.
String.toString:
divide the string into sub string
Reply With Quote
  #5 (permalink)  
Old 01-17-2008
Junior Member
 
Join Date: Jan 2008
Location: Chennai
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
jr.suthan is on a distinguished road
Re: Difference between String.Convert Vs String.ToString

String.Convert will not allow null value
String.ToString will allow null value...
Reply With Quote
  #6 (permalink)  
Old 02-13-2008
Junior Member
 
Join Date: Feb 2008
Location: bangalore
Posts: 18
Thanks: 0
Thanked 2 Times in 1 Post
venkat.rbs is on a distinguished road
Re: Difference between String.Convert Vs String.ToString

Quote:
Originally Posted by jr.suthan View Post
String.Convert will not allow null value
String.ToString will allow null value...
String.Convert:
convert the string from one to another.
String.toString:
divide the string into sub string
Reply With Quote
  #7 (permalink)  
Old 03-24-2008
Junior Member
 
Join Date: Jan 2007
Location: Chennai
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
a_sahayam_811572 is on a distinguished road
Re: Difference between String.Convert Vs String.ToString

See the example.

Line 1 :String str1 = null;
Line 2: Console.WriteLine("->" + Convert.ToString(str1) + "<-";
Line 3: Console.WriteLine("->" + str1.ToString() + "<-");

In the above example,
Line 2 will display the result("-><-"), because Convert.ToString() handle NULL.
Line 3 will throw NullReferenceException because .ToString() does not handle NULL.
Reply With Quote
Reply

  Geeks Talk > Software Development > C#

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
VisiFly is an easy-to-use program to convert your video files into streaming Flash st JobHelper Geeks Lounge 0 02-12-2007 06:21 AM
Convert PowerPoint into video JobHelper Geeks Lounge 0 02-09-2007 06:01 PM
Getting exact recognition string JobHelper Rational Robot 0 01-06-2007 01:32 AM
String handling function in C scott C and C++ 1 07-23-2006 12:22 PM
String into Long norman C and C++ 2 07-13-2006 10:51 PM


All times are GMT -4. The time now is 03:42 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved