469,625 Members | 1,086 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

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.ToString() = "cat1, cat2, cat3"

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

this.categoriesEntry.Items.AddRange(
category.ToString().Replace(" ",String.Empty).Split(new char[]{','})
);
Nov 16 '05 #1
1 1609
Mike,

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.com

"Mike in Paradise" <Mi************@discussions.microsoft.com> wrote in
message news:F7**********************************@microsof t.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.ToString() = "cat1, cat2, cat3"

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

this.categoriesEntry.Items.AddRange(
category.ToString().Replace(" ",String.Empty).Split(new char[]{','})
);

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Keith Hill | last post: by
4 posts views Thread by Paul E Collins | last post: by
3 posts views Thread by Chris Sharman | last post: by
29 posts views Thread by zoltan | last post: by
9 posts views Thread by ankitdesai | last post: by
2 posts views Thread by Jeff | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.