Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
It's already a string... why use ToString()?
Message
 
To
01/04/2002 13:22:08
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00639339
Message ID:
00640147
Views:
15
>>the invocation of method TrazerEdicoes(), returns a XML string. Why I must call .ToString()??
>
>I don't think you have to, but I think it optimizes the code to perform better. Just a guess, I should findn out.

Uh, no...

If the compiler complains it means it can't implicitly convert. The compiler will usually do a pretty good job converting types when possible, but it will not convert objects to specific types even though that information is available via the Reflection classes (GetType() method of any object).

I don't know how this works in VB, but in C# casting ( syntax like: (string) SomeVar;) is usually most efficient because the compiler actually can put the conversion code right into the compiled bnary. Any built in methods for conversion are next, and the slowest mechanism is to use the Convert object (which basically requires the object/type to be copied).

Generally anything generic (like collection class items) will require explicit conversion because those things tend to be objects...
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform