471,863 Members | 1,149 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,863 software developers and data experts.

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 1685
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
NeoPa
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by

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.