What are the best resources to learn writing idiomatic c#? [closed]
Question
I am looking for something like idiomatic ruby for c# programmers
It should:
be for people that can already programm
be terse
not be to basic
just found a better thread for this question on stackoverflow: c-coding-standard-best-practices
Solution
You might want to try Effective C# and More Effective C#, both by Bill Wagner.
I haven't read either of them properly (must get round to doing so some time) but I've heard good things.
Assuming you're using C# 3, I would try to make sure you're familiar with:
- Generics and what type inference on generic methods can do with you
IEnumerable<T>
and iterator blocks- LINQ in general, and LINQ to Objects in particular (other LINQ flavours are useful in some places - LINQ to Objects is useful almost everywhere)
- Delegates, particularly lambda expressions and anonymous methods
- Object and collection initializers
- Extension methods - be aware of them, and consider them for utility methods. In particular they're handy if you want to add your own LINQ operators
OTHER TIPS
Framework Design Guidelines is the only thing i found
If you want to ensure the style of your code is as per Microsoft's recommendations, take a look at StyleCop. Yes, it is very picky, and I don't agree entirely with all the rules, but in the general case it does make for more readable code, which is more consistent between developers.
This is not a bad comparison between C# and Java, which hits most of the C# idioms, but beware that there are two different idioms at work here: C# idioms and .NET idioms. For example, in C#, it is perfectly acceptable to use underscore in identifiers, but not do in VB.NET, therefore while it is not mandated so, it is best practice to never use underscore in public identifiers so that VB.NET can access them.