static void Main(string[] args) { StringCollection str = new StringCollection(); str.Add("geethu"); str.Add("krish"); str.Add("vinnu"); str.Add("raja"); str.Add("honey"); Console.WriteLine("StringCollection elements..."); foreach (string res in str) { Console.WriteLine(res); } String[] arr = new String[] { "one", "two", "three", "four", "five" }; str.AddRange(arr); Console.WriteLine("Adding range of elements to string collection....."); foreach (string res in str) { Console.WriteLine(res); } Console.WriteLine("inserting elements at a specified location....."); str.Insert(1, "rakul"); foreach (string res in str) { Console.WriteLine(res); } Console.WriteLine("checking wheteher the element is present or nor..."); var k = str.Contains("ram"); Console.WriteLine(k); Console.WriteLine("finding the index of a particular element..."); var j = str.IndexOf("raja"); Console.WriteLine(j); Console.WriteLine("finding equality..."); var l = str.Equals("geethu"); Console.WriteLine(l); Console.Read(); }
/** * Método para calcular las variables Unitarias * Usa 2 diccionarios y repite los ciclos hasta que los 2 diccionarios sea iguales */ public Dictionary <string, StringCollection> Unitarias() { Dictionary <string, StringCollection> unitarias = new Dictionary <string, StringCollection>(); bool equal = false; foreach (KeyValuePair <String, Variable> variable in variables) { StringCollection unit = new StringCollection(); unit = variable.Value.Unitarias(); StringCollection unit2 = unit; while (!equal) { for (int i = 0; i < unit.Count; i++) { unit2 = variables[unit[i]].Unitarias(unit); } if (unit.Equals(unit2)) { equal = true; unit = unit2; } else { unit = unit2; } } unit.Add(variable.Key); unitarias.Add(variable.Key, unit); } return(unitarias); }
[Category("NotDotNet")] // SyncRoot != this on 2.0 #endif public void SimpleSyncRoot() { Assertion.Assert(sc.Equals(sc.SyncRoot)); }
static void Main() { StringCollection strcoll = new StringCollection(); strcoll.Add("This"); strcoll.Add("is"); strcoll.Add("string"); strcoll.Add("collection"); strcoll.Add("demo"); Console.WriteLine("String Collection"); foreach (var item in strcoll) { Console.WriteLine(item); } Console.WriteLine("count of string collection"); int x = strcoll.Count; Console.WriteLine(x); Console.WriteLine("****copy to array****"); string[] str1 = new string[strcoll.Count]; strcoll.CopyTo(str1, 0); foreach (var item1 in str1) { Console.WriteLine(item1); } Console.WriteLine("***Add range method***"); string[] str2 = new string[] { "All", "the", "best" }; strcoll.AddRange(str2); foreach (var item2 in strcoll) { Console.WriteLine(item2); } Console.WriteLine("contains method"); bool x1 = strcoll.Contains("collection"); Console.WriteLine(x1); strcoll.Insert(5, "dear"); foreach (var item3 in strcoll) { Console.WriteLine(item3); } bool b = strcoll.Equals("dear"); Console.WriteLine("equals 'dear':{0}", b); Type t = strcoll.GetType(); Console.WriteLine(t); Console.WriteLine("remove element at index 1"); strcoll.RemoveAt(1); foreach (var item4 in strcoll) { Console.WriteLine(item4); } }