I want to use SortedSet in my C# script but unable to use it.

I am using Unity 2018 2.6f1 (64 bit). And using Notepad as an editor to write the scripts.
When I am trying to use this line of code -
SortedSet my_Set1 = new SortedSet();

The error I get is -
error CS0246: The type or namespace name `SortedSet’ could not be found. Are you missing an assembly reference.

Though I am using all the relevant header files -
using System.Collections.Generic;

What do I do now?
I want to use set data structure in my code. Is there any other way of doing it?

SortedSet is one of those things that’s become available with Net 4.x

Go to Project Settings → Player → Other Settings → Configuration and change API Compatibility Level to “.NET 4.x”

I just tried this in a test project and it made SortedSet available. If you were using Visual Studio or something you might need to delete your solution/project files to force Unity to re-create them.

If you don’t want to change that setting (I have some old projects myself that it’d be a bit of a faff in) then you’ll have to resort to using SortedList or sorting a List, making your own class, etc.

Okay now the problem is sorted. The problem was with Scripting Runtime Version.
Changing scripting runtime version to .Net.4.x works.

Following are the steps -

Edit → Project Setting → Player Setting → Other setting → Configuration → Scripting Runtime version

and change it to .Net 4.x