Home > Ask the Microsoft .Net Development Experts > Visual Basic .NET Questions & Answers > System.Convert.ToString(mdblAnswer) or CStr(mdblAnswer)? Which should I use?
Ask The Win Development Expert: Questions & Answers
EMAIL THIS

System.Convert.ToString(mdblAnswer) or CStr(mdblAnswer)? Which should I use?

Samuel Colak EXPERT RESPONSE FROM: Samuel Colak

Pose a Question
Other Win Development Categories
Meet all Win Development Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 17 March 2003
In trying to learn VB.NET from various books, I find that one author uses System.Convert.ToString(mdblAnswer) and another uses the much shorter named function CStr(mdblAnswer). Is there any advantage to using one of these approaches over the other? If so, which approach do you feel is best and why? Thanks so much for sharing your expertise.

>
One thing that is very amusing between us all "experts" is that a lot of knowledge comes from past experiences and "how we feel." I can tell you that when you start dealing with multiple languages, each one changes your perception, and whilst you move from one to another, this begins to make things more fuzzy.

The CSTR function is a derivative from the old BASIC days, back in the 1980s. BASIC stands for:

B-EGINNERS
A-LL-PURPOSE
S-YMBOLIC
I-NSTRUCTION
C-ODE

Now, the CSTR function came about because in those days, each instruction was compiled and held in its interpreted form in a minimal amount of memory. The fewer letters you used for a function, the less memory it consumed and the larger you applications could be. Nowadays, with a couple of gigabytes of memory and 40 GB of HD space, this has become less of an issue.

The .NET Framework attempts to standardize the way in which functions work. And to be honest, whilst you use CSTR in VB.NET, if you decide to make the move to C#, you'll find that a lot of blankets used to pad people in the VB world, have suddenly been removed.

You might even notice that with each object there is usually a sub property 'ToString' -- this is exactly the same.

So the quick answer, is no -- it makes no difference; it's all personal choice.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Visual Basic .NET
Access VB .NET Windows control on client side
Drop down list server control creates error message
Converting floating values to byte form
Datagrid issue: 'onselection' is not populating
Read data from parallel port
What is the use of these constructors?
Give me an ODBC connect, with SQL authentication
Converting EXE-files to VB components
Generating classes like we did in VB6
Manipulating text through VB.NET

VB.NET
Access VB .NET Windows control on client side
Converting floating values to byte form
Read data from parallel port
Converting EXE-files to VB components
Generating classes like we did in VB6
Manipulating text through VB.NET
Converting Windows applications to VB .NET
How to add a key to a listview item in VB.NET
Accessing .NET components from VBScript
How I can assign an untyped dataset to a typed dataset?

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Windows Development - White Papers, News and Expert Advice
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts