What's your favorite feature in .NET? [closed]

旧街凉风 提交于 2019-12-05 01:00:41

问题


There are lots of features in .NET. Some language related, others will be related to the framework itself and having the ability to access/do/perform xyz. So for fun, I was wondering what the community's favorite features in .NET or ASP.NET include?

This is a community wiki question as its mainly for polling purposes to see what kind of a response there is for all aspects of .NET

Be specific, try to include something about it like a code sample.

Example categories and topics:

  • DLR
  • Linq
  • Expressions
  • WPF
  • Generics
  • WCF

回答1:


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;
}



回答2:


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.




回答3:


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?




回答4:


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);



回答5:


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




回答6:


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




回答7:


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.




回答8:


In no particular order

Reflection
Linq
Lambdas

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




回答9:


Code-Behind files

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




回答10:


Attributes (Java: Annotations).




回答11:


generics and expressions trees




回答12:


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++)




回答13:


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




回答14:


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.




回答15:


The Combo: Delegates + Anonymous Methods + Lambda Expression




回答16:


  • 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.



回答17:


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.



来源:https://stackoverflow.com/questions/237365/whats-your-favorite-feature-in-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!