473,466 Members | 1,382 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

I need you help...experts...

Dear All Experts

I would like to know what's the different between
Convert.ToString(object)
object.ToString()
(string)object

??

thanks

if the object is null
which one will not flow exception?

Thanks a look

Jan 23 '06 #1
2 1149
Sounds suspiciously like homework to me...

The details of object.ToString and Convert.ToString(object) can all be found
on MSDN2 very easily. The former will always throw an exception if object is
null, the latter may/may-not depending on the exact formatter used (in the
overloaded form) [EFR].

(string)object is a simple cast of the object to a string, so if object is
null this will always succeed (since string is a reference type, and
reference types can always accept null values). I wouldn't say it doesn't
"flow exception", simply because there *is* no exception to flow in this
case - however, it doesn't throw one, if that's what the question is.

Or just say that the dog ate it ;-p

(apols if I am wrong about the howework thing, but I'm feeling cynic today)

Marc
Jan 23 '06 #2
> if the object is null
which one will not flow exception? all of them can throw exception,
however, AFAIR of object is equal to null then (string)object will return
null.

Convert.ToString(object) tries to convert object into string. For this it
first checks if
object supports convesion intefaces IConvertible and IFormattable and if not
calls object.ToString() method.

object.ToString(). if underlying type overrides ToString() method then it is
used to obtain string value. If this method is not overriden then default
object.ToString() is used, this method will return object's type name
object.GetType().ToString();

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"ºa¤Ö" <?a?ã@?Ãl.???q> wrote in message
news:Oz*************@tk2msftngp13.phx.gbl... Dear All Experts

I would like to know what's the different between
Convert.ToString(object)
object.ToString()
(string)object

??

thanks

if the object is null
which one will not flow exception?

Thanks a look

Jan 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: abcd | last post by:
kutthaense Secretary Djetvedehald H. Rumsfeld legai predicted eventual vicmadhlary in Iraq mariyu Afghmadhlaistmadhla, kaani jetvedehly after "a ljetvedehg, hard slog," mariyu vede legai pressed...
12
by: Vibhajha | last post by:
Hi friends, My sister is in great problem , she has this exam of C++ and she is stuck up with some questions, if friends like this group provides some help to her, she will be very grateful....
11
by: blah | last post by:
Need python Pro at newtopython@googlegroups.com , if u wanna help, plz reply to that address. We are python beginners. need a real good Python Programmer for Help. TIA!! -- * Posted with...
22
by: OHM \( Terry Burns \) | last post by:
I was thinking about community the other day, and wondering what would be the holy grail for a developer in need. I mean, we do get help here, but its done on a best endeavours basis and its really...
5
by: Kevin Carne | last post by:
First, Merry Christmas. I have been doing intensive Java programming for two years in school (no choice on the language), but now I need to return to C++ because my resume is filled with it both in...
9
by: Mickey Segal | last post by:
The long-simmering Eolas patent dispute: http://www.microsoft.com/presspass/press/2003/oct03/10-06EOLASPR.mspx has led to an optional Microsoft Update: http://support.microsoft.com/kb/912945/en-us...
2
by: clinttoris | last post by:
Hello, If someone could help me it would be appreciated as I am not having much luck. I'm struggling with my asp code and have some questions relating to asp and oracle database. First...
6
by: MLH | last post by:
Will someone please remind me of a keyword to search A97 HELP for the topic(s) covering details of how I can read values from any of the fields in record currently selected in a combo-box. For...
51
by: cool_ratikagupta | last post by:
hello friends i ha just started learning c can u all give me the tips to make myself strong in c lanuage . as i want to be the best in watever i do . so just a request from all of u here plz help...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.