Add element to SortedSet and returns a value that indicates if it was successfully added in CSharp

Description

The following code shows how to add element to SortedSet and returns a value that indicates if it was successfully added.

Example


using System;/*from  w w w .ja v a  2 s  .c  o m*/

using System.Collections.Generic;

    
public class MainClass{
  public static void Main(String[] argv){  
    SortedSet<int> evenNumbers = new SortedSet<int>();
    for (int i = 0; i < 5; i++){
        evenNumbers.Add(i * 2);
    }
    
    foreach(int i in evenNumbers){
        Console.WriteLine(i);
    }  
  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary