Solved

Remove all spaces in c#

Posted on 2014-02-06
4
248 Views
Last Modified: 2014-02-07
Hi Experts,

I have below mapping class and from client side will get registrationnumber data in the form of  123 456 7899 and should trim all the spaces (1234567899) and save it to database.what is best way to achieve this?

public class UserMapp
{

public void Map(user userobj, customer custobj)
{

userobj.registrationnumber=custobj.registrationnumber; 

}

}

Open in new window

0
Comment
Question by:ksd123
4 Comments
 
LVL 4

Accepted Solution

by:
jatkin earned 100 total points
Comment Utility
You could use:
userobj.registrationnumber=custobj.registrationnumber.Replace(" ", ""); 

Open in new window


James
0
 
LVL 17

Assisted Solution

by:Barry Cunney
Barry Cunney earned 100 total points
Comment Utility
public class UserMapp
{

public void Map(user userobj, customer custobj)
{

userobj.registrationnumber=custobj.registrationnumber.ToString().Replace(" ", string.empty); 

}

}

Open in new window

0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
In addition - don't forget that is throwing information away which you can not restore unless the format is always (not 999,999 from a million times) the same.

I've experienced similar, this happens always and then later very occasionally it is different, how do we restore it to the original format.  Ooops!!!!!
0
 

Author Closing Comment

by:ksd123
Comment Utility
Thank  you all
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now