C# | Remove a specified item from SortedSet Last Updated : 01 Feb, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report SortedSet class represents the collection of objects in sorted order. This class comes under the System.Collections.Generic namespace. SortedSet<T>.Remove(T) Method is used to remove a specified item from the SortedSet. Properties: In C#, SortedSet class can be used to store, remove or view elements. It maintains ascending order and does not store duplicate elements. It is suggested to use SortedSet class if you have to store unique elements and maintain ascending order. Syntax: public bool Remove (T item); Here, item is the specified item which is to be removed from the SortedSet. Note: If the SortedSet<T> object does not contain the specified element, the object remains unchanged and no exception is thrown. Example 1: CSHARP // C# code to remove a specified element // from the SortedSet using System; using System.Collections.Generic; class GFG { // Driver code public static void Main() { // Creating a SortedSet of integers SortedSet<int> mySortedSet = new SortedSet<int>(); // adding elements in mySortedSet mySortedSet.Add(2); mySortedSet.Add(4); mySortedSet.Add(6); mySortedSet.Add(8); mySortedSet.Add(10); // Removing element "4" if found mySortedSet.Remove(4); // Displaying the elements in mySortedSet foreach(int i in mySortedSet) { Console.WriteLine(i); } Console.WriteLine("After Using Method"); // Removing element "14" if found mySortedSet.Remove(14); // Displaying the element in mySortedSet foreach(int i in mySortedSet) { Console.WriteLine(i); } } } Output: 2 6 8 10 After Using Method 2 6 8 10 Example 2: CSHARP // C# code to remove the specified // element from SortedSet using System; using System.Collections.Generic; class GFG { // Driver code public static void Main() { // Creating a SortedSet of strings SortedSet<string> mySortedSet = new SortedSet<string>(); // adding elements in mySortedSet mySortedSet.Add("A"); mySortedSet.Add("B"); mySortedSet.Add("C"); mySortedSet.Add("D"); mySortedSet.Add("E"); // Removing element "C" if found mySortedSet.Remove("C"); // Displaying the element in mySortedSet foreach(string str in mySortedSet) { Console.WriteLine(str); } } } Output: A B D E Comment More infoAdvertise with us Next Article C# | Remove a specified item from SortedSet S Sahil_Bansall Follow Improve Article Tags : Misc C# CSharp-method CSharp-Generic-SortedSet CSharp-Generic-Namespace +1 More Practice Tags : Misc Similar Reads SQL Commands | DDL, DQL, DML, DCL and TCL Commands SQL commands are crucial for managing databases effectively. These commands are divided into categories such as Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), Data Query Language (DQL), and Transaction Control Language (TCL). In this article, we will e 7 min read TCP/IP Model The TCP/IP model is a framework that is used to model the communication in a network. It is mainly a collection of network protocols and organization of these protocols in different layers for modeling the network.It has four layers, Application, Transport, Network/Internet and Network Access.While 7 min read Basics of Computer Networking A computer network is a collection of interconnected devices that share resources and information. These devices can include computers, servers, printers, and other hardware. Networks allow for the efficient exchange of data, enabling various applications such as email, file sharing, and internet br 14 min read Java Programs - Java Programming Examples In this article, we will learn and prepare for Interviews using Java Programming Examples. From basic Java programs like the Fibonacci series, Prime numbers, Factorial numbers, and Palindrome numbers to advanced Java programs.Java is one of the most popular programming languages today because of its 8 min read Unified Modeling Language (UML) Diagrams Unified Modeling Language (UML) is a general-purpose modeling language. The main aim of UML is to define a standard way to visualize the way a system has been designed. It is quite similar to blueprints used in other fields of engineering. UML is not a programming language, it is rather a visual lan 14 min read Second Largest Element in an Array Given an array of positive integers arr[] of size n, the task is to find second largest distinct element in the array.Note: If the second largest element does not exist, return -1. Examples:Input: arr[] = [12, 35, 1, 10, 34, 1]Output: 34Explanation: The largest element of the array is 35 and the sec 14 min read Python Lists In Python, a list is a built-in dynamic sized array (automatically grows and shrinks). We can store all types of items (including another list) in a list. A list may contain mixed type of items, this is possible because a list mainly stores references at contiguous locations and actual items maybe s 6 min read Introduction to Java Java is a high-level, object-oriented programming language developed by Sun Microsystems in 1995. It is platform-independent, which means we can write code once and run it anywhere using the Java Virtual Machine (JVM). Java is mostly used for building desktop applications, web applications, Android 4 min read f-strings in Python Python offers a powerful feature called f-strings (formatted string literals) to simplify string formatting and interpolation. f-strings is introduced in Python 3.6 it provides a concise and intuitive way to embed expressions and variables directly into strings. The idea behind f-strings is to make 5 min read Python Operators In Python programming, Operators in general are used to perform operations on values and variables. These are standard symbols used for logical and arithmetic operations. In this article, we will look into different types of Python operators. OPERATORS: These are the special symbols. Eg- + , * , /, 6 min read Like