views:

641

answers:

17
+12  A: 

Generics. Excellent for not rolling your own container classes. Available since C# 2.0 .

public T Remove<T>(T item) {
  foreach (T t in this.list) {
    if (t.equals(item)) {
      list.delete(t);
      return t;
    }
  }
  return null;
}
Michael Gundlach
+1 for that. Having tasted from the Fountain of Generics, I find it hard to use a language without. "Sure, I can just use a List<MyClass> here! Oh... wait... crap."
Michael Stum
All hail .net generics +1
annakata
+10  A: 

Reflection. Let's face it: without Reflection, .NET is just a C wanna-be. Or maybe, if we want to be generous, a Java wanna-be - but Java has reflection, and kinda smells like a Pascal wanna-be otherwise, so let's avoid that argument and just accept that .NET wants dearly to be a portable assembler with enough metadata to make VB work.

I've heard people claim that you should avoid using Reflection because it slows down your program and makes life difficult for static analysis tools... Frankly, that's a load of manure. Functions slow C down, but who would write C code without functions? Macros make static analysis difficult for C, but C is nothing without macros! Therefore, i urge you to go nuts - if Reflection makes your life easier, use it. Heck, abuse it. Bend Your .NET Language of Choice to your will and show it who is boss - with Reflection as your trusty oak club of will-bending. Then sip your iced tea and gaze upon the works of your hands, confident that no one will dare say you are not the master of your tools.

Shog9
Great answer. I hardly write a program that doesn't utilize reflection. And what if it is slow? You don't have to put it in all your inner loops! And static analysis tools are like very challenged colleagues. You can't be expected to write code that everybody understands.
Guge
+4  A: 

Linq To SQL and the ADO.NET Entity Framework, wonderful features...

CMS
Well, a lot of people have reservations about EF (over-complicated in many cases, and forces you to use a base-class; contrast to LINQ-to-SQL or NHibernate)
Marc Gravell
A: 

I don't really have any language features that I would call 'favourite'. I mean I love generics, and I love LINQ, amongst many other things, but they're all half-baked imitations of things which work better in other languages.

Example: generics are great, but nowhere near as powerful or useful as C++ templates. Example 2: The LINQ extension methods are great, but nowhere near as powerful or useful as open classes + plain old methods in ruby.

And so on and so forth.

To be honest, the thing I like best about .NET is it's speed, and deployment model. Being able to use all these half-baked but still great features is infinitely preferable to not being able to use them at all, because the runtime is painfully slow (eg ruby), or because nobody can load your dll unless they used the exact same variant of your crazy compiler in release mode with certain flags (eg C++)

Orion Edwards
.NET generics are *different* to C++ templates; in some ways they are a lot *more* powerful than their C++ cousins, and in other ways less.
Marc Gravell
+2  A: 

ASP.NET state management and WebForms.

WebForms cop a bad name mostly because so many people don't use them right and don't understand how state should be used.

When used correctly, with ViewState disabled where it's not needed, data repopulation when it should be done, etc WebForms make web development a lot easier than when you use something like PHP or ASP.

Slace
A: 

ADO.NET, Specifically strongly typed DataSets used with DataAdapters. It makes code management for interfacing with Databases and stored procedures a doddle.

Ady
Give me a simple class any day... just an opinion, though. For DB work, LINQ-to-SQL or NHibernate do a much better job.
Marc Gravell
+7  A: 

I think there's a lot of great features in .NET, but my vote goes for the things under the hood that makes this platform one of the best software technology choices out there:

  • Garbage Collection - Being blissfully ignorant about when the memory for your object has to be deallocated is a great gift. In other languages (C++), if you don't clean up after yourself, you get memory leaks and blue screens.

  • Just in Time Compilation - The compiler optimizes each method before use, removing redundant or unoptimized code.

  • AppDomains - When a .NET app dies, it doesn't de-stablize your system.

  • Side by Side Execution and XCopy Deployment - No more DLL Hell. Nuff said.

  • Platform Abstraction - The framework hides a lot of the versioning details of the native Win32 Api.

  • Language Neutral - Whether it's VB.NET, C# or whatever language you prefer, it's all MSIL. Being able to inherit a C# class in VB.NET is pretty cool.

  • Interopability - Ability to call legacy Win32 API, interop with COM+, etc

Others:

  • Reflection, as previously stated, is killer.
  • Xml Configration support is far superior to Java's property file syntax.

Do I really have to pick one?

bryanbcook
+7  A: 

Delegates; I like the ability to write functional-style code, without the pain of F#, and the untyped function pointers of C++. Add to that the very nice lambda syntax (C#), and the compiler support for captures, and they are great! I prefer C# captures to java captures, since the value can flow in either way (the variable, rather than the value, is captured).

As a trivial example - how painful isn't this?

string name = // something interesting
var item = list.Find(x => x.Name == name && x.Status == Status.Open);
Marc Gravell
A: 

GDI+

Graphics used to be real hard to do. With GDI+ it has become painless. And there is so much functionality in it. Things like Matrix, Path, Transparency, SmoothingMode are great, and very fun to play with.

And if that doesn't give you enough, you can also use DirectDraw or Direct3D.

Guge
GDI+ is a Win32 API. I guess you meant System.Drawing.
Justin
A: 

Attributes (Java: Annotations).

EricSchaefer
A: 

The Combo: Delegates + Anonymous Methods + Lambda Expression

Quaky
+3  A: 

The garbage collector. You take it for granted after a while.

Dave Markle
+2  A: 

In no particular order

Reflection
Linq
Lambdas

Hell, there's been cases where I've combined all three in a single statement.

toast
+2  A: 

Code-Behind files

..a huge step from the Classic ASP era (and php?)

Andreas Grech
A: 
  • LINQ
  • The fact everything goes to IL, which means you can implement any language on top of it and get things like generics and LINQ for very little
  • WF - I know it's complicated and not the greatest implementation of this but if you spend time with it, you find it does work well for it's target purpose.
Robert MacLean
A: 

Windows Communication Foundation (WCF) is my favourite feature of .NET. It is a big step forward from plain Web Services. It also embraces the ever increasing in popularity REST design.

Przemek
+1  A: 

generics and expressions trees

Damien McGivern