gjshah7254
6/16/2014 - 5:36 AM

Dynamically Add items to an Array C#

Dynamically Add items to an Array C#

using System.Collections;//NameSpace


//Adding new items Dynamically
ArrayList list = new ArrayList();
list.Add("Item");


//Checking if a string exists within an Array or not
if (list.Contains(""))
{
}

foreach (string i in list)
	{
	    Console.WriteLine(i);//prints items individually
	}
string IgnoreURLTermsString = "test1,test2";
string[] IgnoreURLTerms = IgnoreURLTermsString.Split(',');


Another way of splitting in a loop it
string[] ids = txtIds.Text.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            foreach (string id in ids)
            {
            }