Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

String functions

Posted on 2006-05-02
8
Medium Priority
?
277 Views
Last Modified: 2010-04-17
Hi,

In .net, will Trim() function internally calls ToString() function ?

Regards,

Badri Narayanan R
0
Comment
Question by:r_badris
6 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 16584360
Hi r_badris,

not if Option Strict is set to ON

Cheers!
0
 

Author Comment

by:r_badris
ID: 16584370
hi emoreau,

can you please suggest me in c#.

Regards,

Badri narayanan R.

0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 300 total points
ID: 16584381
in C#, Option Strict is always ON.

So you cannot do YourNumericVariable.Trim, you need to do YourNumericVariable.ToString().Trim()
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Expert Comment

by:jphillips247
ID: 16585224
There should be no reason to call the Trim() function on Numeric Data Types as Trim only removes leading and trailing spaces and Numeric Data Types by there very nature does not have spaces.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 16592230
>There should be no reason to call the Trim() function on Numeric Data Types as Trim only removes leading and
>trailing spaces and Numeric Data Types by there very nature does not have spaces.

ToString() is not only for numeric data types. Every user's class or struct can have a ToString() function overriden.
In C# it is mandatory to call ToString() before trying to apply Trim() to an object that is not originally a string.
0
 
LVL 3

Expert Comment

by:jphillips247
ID: 16595396
But why would you call trim() on a non string data type to beign with even if you where converting it to a string?
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Six Sigma Control Plans

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question