Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SortedList<TKey, TValue> not defined in Systems.Collections.Generic using .NET 4.0

Tags:

c#

I downloaded a library that uses the generic version of SortedList, but when I try to compile it the following error pops up:

The type or namespace name 'SortedList' does not exist in the namespace 'System.Collections.Generic' (are you missing an assembly reference?)

I tried to fix it using the full namespace, System.Collections.Generic.SortedList<string, string> but still no luck, the same error.

I looked up in MSDN and it says that SortedList is supported on .NET 4.0 (the version I am currently using).

Also, my projects references the mentioned namespaces.

This is the code (the error gets repeated more than once, for every reference to SortedList):

public class Map
{
    public SortedList<string, Tileset> Tilesets = new SortedList<string, Tileset>();
    public SortedList<string, Layer> Layers = new SortedList<string, Layer>();
    public SortedList<string, ObjectGroup> ObjectGroups = new SortedList<string, ObjectGroup>();
    public SortedList<string, string> Properties = new SortedList<string, string>();
    public int Width, Height;
    public int TileWidth, TileHeight;
}
like image 649
Pacha Avatar asked Nov 29 '25 02:11

Pacha


1 Answers

Right-click on your project's References and select "Add Reference". Select "Assemblies", and put a tick next to "System". Click on "OK" and it should now be fixed.

like image 83
Steve Smith Avatar answered Nov 30 '25 15:11

Steve Smith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!