Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# data structures

Tags:

c#

I'm building an app in C#, however I'm new to the language though its pretty easy to learn because its too damn similar to Java.

However, I'm getting lost with the data structures as I haven't found a list of comprehensive available data structures with their methods like how Java has them.

Anyone has a reference list of available data structs for C# and their methods?

like image 209
nubela Avatar asked Jan 16 '10 21:01

nubela


3 Answers

Most of the data structures you'll use in C# are contained in the System.Collections.Generic namespace. There are some rarely used data structures in the System.Collections.Specialized namespace. Also, there are some older, non-generic versions of data structures that are mostly deprecated since the introduction of generics in C# 2.0 available in the System.Collections namespace.

Scott Mitchell has a nice introductory article set about some data structures in .NET: An Extensive Examination of Data Structures Using C# 2.0.

If you're coming from a Java background, you'll notice that unlike Java, .NET data structures are named after their function, not the way they are implemented.

like image 70
mmx Avatar answered Nov 06 '22 14:11

mmx


You're going to love them. C# data structures combined with LINQ offer so much more than Java. Check out the System.Collections.Generic namespace. One important note that almost any generic collection implements the IEnumerable<T> interface one way or other and you can LINQ to any IEnumerable<T> object:

List<SomeClass> yourList = new List<SomeClass>();
// Add elements ...
var redElementsOnly = yourList.Where(e => e.IsRed);

Check out the System.Linq.Enumerable class for a complete list of what LINQ can do for you.

like image 27
Tamas Czinege Avatar answered Nov 06 '22 14:11

Tamas Czinege


You may find these MSDN pages useful: The C# Programming Language for Java Developers

like image 1
Paolo Avatar answered Nov 06 '22 16:11

Paolo