String Writer

my tech stuffs…

Convert/Copy ICollection to Array

with one comment

This is just a code sample to copy the values from any ICollection type to array. I don’t know why some methods in .Net still expects only array type of input, why not ICollection type!!! So I had to convert every time to array type. This is really boring :( so this helper method is handy for me.


/// <summary>
/// Arrays from ICollection object.
/// </summary>
/// <param name="collection">ICollection object</param>
/// <returns>String array type</returns>
public string[] GetArrayFromICollection(ICollection collection)
{
   string[] array = new string[collection.Count];
   collection.CopyTo(array, 0);
   return array;
}

About these ads

Written by visvabalaji

February 7, 2007 at 6:28 am

Posted in C#

Tagged with

One Response

Subscribe to comments with RSS.

  1. Youre so cool! I dont suppose Ive read something like this before. So nice to seek out any individual with some original thoughts on this subject. realy thanks for starting this up. this web site is one thing that is needed on the web, someone with somewhat originality. useful job for bringing one thing new to the internet

    news feed

    February 7, 2013 at 3:21 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: