Is there a good method to convert the object of type
NameObjectCollectionBase.KeysCollection to an array of string without
enumerating? Or, let define the problem in a different way. I have an
instance of KeysCollection class, and I want to join the elements of this
collection into a single string, seperated by commas. Any ideas? Thanks in
advance.
"Candan Akyol" <cak...@digilane.com> wrote in message
news:uqFBBiK3BHA.2680@tkmsftngp04...
You are going to have to do this manually. And easy way to do this
would be:
// The StringBuilder that will be used to create the list.
StringBuilder pobjBuilder = new StringBuilder();
// Cycle through the objects. Assume pobjCollection is the KeysCollection.
foreach (string pstrString in pobjCollection)
{
// Append the string.
pobjBuilder.Append(pstrString);
// Append a comma.
pobjBuilder.Append(',');
}
// If there is anything in the string, then that means one item
// was placed in the string, along with a comma. Take off the last comma
// if this is the case.
if (pobjBuilder.Length > 0)
// Trim off the last comma.
pobjBuilder.Remove(pobjBuilder.Length - 1, 1);
// Get the string.
string pstrString = pobjBuilder.ToString();
Hope this helps.
--
- Nicholas Paldino [.NET MVP]
- nicholas...@exisconsulting.com
"Candan Akyol" <cak...@digilane.com> wrote in message
news:uqFBBiK3BHA.2680@tkmsftngp04...
"Nicholas Paldino [.NET MVP]" <nicholas...@exisconsulting.com> wrote in
message news:uvrZFvK3BHA.2228@tkmsftngp07...