System.Windows.Forms.ListBox.IntegerCollection.Add C# (CSharp) Method

Add() public method

public Add ( int item ) : int
item int
return int
			public int Add (int item)
			{
				// This collection does not allow duplicates
				if (!list.Contains (item)) {
					list.Add (item);
					list.Sort ();
					owner.CalculateTabStops ();
				}
				
				return list.IndexOf (item);
			}
			

Usage Example

Example #1
0
		[Test] // AddRange (ListBox.IntegerCollection)
		public void AddRange2 ()
		{
			ListBox.IntegerCollection ints = new ListBox.IntegerCollection (
				listBox);
			ints.Add (3);
			ints.Add (1);
			ints.Add (-5);
			ints.Add (4);
			ints.Add (2);

			col.Add (5);
			col.Add (3);
			col.Add (12);
			col.AddRange (ints);

			Assert.AreEqual (7, col.Count, "#1");
			Assert.AreEqual (-5, col [0], "#2");
			Assert.AreEqual (1, col [1], "#3");
			Assert.AreEqual (2, col [2], "#4");
			Assert.AreEqual (3, col [3], "#5");
			Assert.AreEqual (4, col [4], "#6");
			Assert.AreEqual (5, col [5], "#7");
		}