Wednesday, February 9, 2011

C#/.NET, what to look at?

I see lots of job ads for C#/.NET programmers, so I thought it could be a good idea to have had a look at it.

After looking at a few tutorials I found nothing really new to me. Just a language with a syntax somewhere between Java and C++ (arguably nicer than both though).

So, what features in particular should I look at? What are some special features? What's the reason that C#/.NET is so large? What are some killer features or perhaps some really evil language gotchas?

Links and code examples are very welcome.

I am using the Mono-implementation on Linux.

  • The .Net Framework library is more important than the language.

    Jon Skeet : It's the combination which is important. LINQ would be significantly less useful without extension methods, for example.
  • In C# 3.0 Linq (Language Integrated Query) is worth looking at.

    From Ash
  • You can find some of the not so obvious features here

    http://stackoverflow.com/questions/9033/hidden-features-of-c

    And yes, the framework is the largest selling point.

  • Exception handling, garbage collection, reflection, a unified type system, machine architecture independence and performance are the main advantages the .NET CLR. The Base Class Libraries are quite comprehensive and comprehensible. Both C# and VB.NET are first class languages for building applications on this platform. Consider learning both.

    From Hafthor
  • Compared with Java:

    • The "using" statement (try/finally is rarely explicit in C#) (C# 1)
    • Delegates as a first class concept (C# 1)
    • Properties and events as first class concepts (C# 1)
    • User-defined value types (C# 1)
    • Operator overloading (use with care!) (C# 1)
    • Iterator blocks (C# 2)
    • Generics without type erasure (C# 2)
    • Anonymous methods (C# 2)
    • Partial types (good for code generation) (C# 2)
    • Object and collection initializers (C# 3)
    • Lambda expressions (C# 3)
    • Extension methods (C# 3)
    • Expression trees (C# 3)
    • Query expressions (aka query comprehensions) (C# 3)
    • Anonymous types (mostly used in query expessions) (C# 3)

    They're the things I miss from C# when I write in Java, anyway. (That's not an exhaustive list of differences, of course.) Which ones are most important to you is subjective, of course. From a simple "getting things done" point of view the using statement is probably the single biggest pragmatic gain, even though it only builds a try/finally block for you.

    EDIT: For quick examples of the C# 2 and 3 features, you might want to look at my Bluffer's Guide to C# 2 and the equivalent for C# 3.

    kigurai : Thanks for the solid answer!
    From Jon Skeet
  • Killer feature: super fast Windows programming with Visual Studio.

    From supermedo

0 comments:

Post a Comment