Hidden Features of C#? [closed] Ask Question

Hidden Features of C#? [closed] Ask Question

This came to my mind after I learned the following from this question:

where T : struct

We, C# developers, all know the basics of C#. I mean declarations, conditionals, loops, operators, etc.

Some of us even mastered the stuff like Generics, anonymous types, lambdas, LINQ, ...

But what are the most hidden features or tricks of C# that even C# fans, addicts, experts barely know?

Here are the revealed features so far:


Keywords

Attributes

Syntax

Language Features

Visual Studio Features

Framework

Methods and Properties

Tips & Tricks

  • Nice method for event handlers by Andreas H.R. Nilsson
  • Uppercase comparisons by John
  • Access anonymous types without reflection by dp
  • A quick way to lazily instantiate collection properties by Will
  • JavaScript-like anonymous inline-functions by roosteronacid

Other

ベストアンサー1

これは厳密には C# ではありませんが、必要な範囲で実際に使用している人を見たことがありませんSystem.IO.Path.Combine()。実際、Path クラス全体が非常に便利ですが、誰も使用していません。

すべての本番アプリには、そうあるべきではないにもかかわらず、次のようなコードが含まれているに違いありません。

string path = dir + "\\" + fileName;

おすすめ記事