By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,866 Members | 1,704 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,866 IT Pros & Developers. It's quick & easy.

Parsing Names for From Flags Enumerated Value, removing Spaces

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.