473,574 Members | 2,817 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parsing Names for From Flags Enumerated Value, removing Spaces

Is there a more effcient way of removing the spaces from the names for a
Enumerated value that has several values when you split it)???

When you do a toString it puts ,<SPACE> between the entries

eg. category.ToStri ng() = "cat1, cat2, cat3"

What I am currently doing..(and I use this a lot..)

this.categories Entry.Items.Add Range(
category.ToStri ng().Replace(" ",String.Empty) .Split(new char[]{','})
Nov 16 '05 #1
1 1787

Looking at the overrides for the ToString method, it doesn't look like
there is a better way to do that. You could enumerate through the values,
and write the string yourself, but it seems easier to just do the replace
(although I imagine it is less efficient).

It's easy enough to place this sort of code into a helper function which
would return the appropriate string to you.

Hope this helps.
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Mike in Paradise" <Mi************ @discussions.mi crosoft.com> wrote in
message news:F7******** *************** ***********@mic rosoft.com...
Is there a more effcient way of removing the spaces from the names for a
Enumerated value that has several values when you split it)???

When you do a toString it puts ,<SPACE> between the entries

eg. category.ToStri ng() = "cat1, cat2, cat3"

What I am currently doing..(and I use this a lot..)

this.categories Entry.Items.Add Range(
category.ToStri ng().Replace(" ",String.Empty) .Split(new char[]{','})

Nov 16 '05 #2

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

Similar topics

by: Keith Hill | last post by:
Is there a way to represent a style enum in XML Schema? Say I have a flags enum like so: public enum dayOfWeek { Mon, Tue, Wed, All = Mon | Tue | Wed; }
by: LFM | last post by:
I have a table I'm importing from our SQL accounting database. The Employee Name is in one field. For the purpose of my needs, I need to extract the last name, first name and middle initial. So, if the name format is: LastName, Firstname MiddleInitial Example entries are: Doe, John Doe, John P Doe, John P.
by: Paul E Collins | last post by:
The help file says that "bit fields can be combined using a bitwise OR operation, whereas enumerated constants cannot", and yet this code works: enum Blah { a, b, c }; // without .... Blah x = Blah.a | Blah.b; So what is the purpose of the Flags attribute? I understand it's potentially useful for reflection, so that (for example) the...
by: Chris Sharman | last post by:
Are spaces allowed in names ? Eg <input name="my field" type="text" value="my data"> The html4 dtd seems to say this is cdata, which allows embedded single spaces, but say agents may trim leading & trailing space, and should replace any whitespace character(s) with a single space. It then goes on to give further constraints "not expressed...
by: zoltan | last post by:
Hi, The scenario is like this : struct ns_rr { const u_char* rdata; }; The rdata field contains some fields such as :
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics" portions of Babe Ruth page (http://www.baseballprospectus.com/dt/ruthba01.shtml) and store that info in a CSV file. Also, I would like to do this for...
by: Chris | last post by:
Hi everyone, I'm trying to parse through the contents of some text files with regular expressions, but am new to regular expressions and how to use them in VB.net. I'm pretty sure that the regular expressions are correct as I got them from regexlib.com and tested them in the Regulator and Expresso. The problem is I tested this function...
by: Jeff | last post by:
I have some custom tags I'm parsing, they look like this: <edit name="some_value" name2="some_value" name3="value with spaces"> I had just been splitting on whitespace, until I though of the value with whitespace already in it: '/\s+/' Is there a lightweight easy way to do this in PHP? In perl this is
by: Benny the Guard | last post by:
I have become familiar with optparse code to parse various options into a program. But right now having some difficulties with a new project I am working on (not a class project, just a new script). What I need is a command line util that can take various flags, these are 100% inclusive with no overlap. Easy, but now I want to also create some...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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 we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.