iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🥺

C# Fundamentals: What Beginners Really Need to Know Beyond the Basics

に公開
2026/05/08
2件

Characteristic Aspects of C#

C# Evolves Quickly 💨

  • Major updates occur annually in recent years
  • New syntax and programming styles are being added constantly.
  • Furthermore, these new styles are often more convenient and performant.
  • For those who knew C# from even a little while ago, it feels like an entirely different language.
Explanation

C# changed slowly until version 6.0, but things started to shift from 7.0, and since 8.0, it has been changing every year.

Specifically, the pages starting from page 7 of the following slide deck are helpful!

While some versions bring smaller changes, here are some of the biggest ones:

  • Became "null-safe" (8.0)
  • Pattern matching (7.0 - 10.0)
  • Ability to write code like a script (9.0 - 10.0)
  • Reduced one level of indentation for all code (10.0)
  • Raw string literals that allow newlines and indentation (11.0)
  • Changed how arrays and collections are written (12.0)
  • Ability to execute as if it were a script (14.0)

Since it can now be written like a script, the sample code in introductory articles needs to be completely rewritten. Before that, beginners had to write boilerplate code every time...

Null safety and pattern matching have changed the language to the point where it feels like a different language (which I suspect is true for other languages as well).

The reduction in indentation and collection expressions have significantly changed the feel of everyday coding. In particular, despite people saying "we should reduce indentation," the reality is that the language previously made it impossible in many places; seeing those limitations removed has made a huge difference in readability and saving editor screen space.

C# Code from 20 Years Ago Still Runs

  • It is a language that puts tremendous effort into backward compatibility.
  • It rarely stops working.
  • It is nice not to have to worry about version differences, but...
  • Consequently, it will even run old coding styles that nobody writes anymore.
Explanation

"If it works, why not use the old style? 🤨"
That is not a luxury you have in C#.

Just because old code still runs doesn't mean it's fine to use it today.

  • It is error-prone.
  • Performance is poor.

There are many patterns that are problematic if you use them now. It leaves in things that other languages would deprecate. There is rarely a reason to use old coding styles in new code.

Introductory Articles and Videos Are Unreliable

  • Because it evolves quickly but never stops running old code, information is often not updated.
  • Even if it is updated, it often explains things in an "Old → New" sequence, which creates unnecessary noise.
  • Make sure to carefully check which version (language and runtime) the information applies to!
Explanation

Information from 20 or 10 years ago often appears with a face that says, "I'm the latest!"...
This is probably why there is no end to beginners trying to compile with csc...

In the case of C#, my impression is that information from 5 years ago is unusable, and even information from 3 years ago is "a bit suspicious."
(So, I wonder what the lifespan of this article will be... maybe 3 years?)
Unless you verify if it's still usable or if there is a better way, it's not helpful.

Even long-established sites are problematic because they retain outdated information that you no longer need to do or know, causing confusion. The official manuals can sometimes be like that, too.

C# Opinions Vary Among Developers

  • Because it evolves quickly but never stops running old code, knowledge is rarely updated.
  • This leads to situations where those who keep up with the trends 🧐 and those who don't 😴 end up "saying completely different things... 🤔"
  • It is also common for people to have written a lot of C# but to have only worked in old environments, leading to a lack of awareness about modern practices.
  • Always check if the person giving advice is actually keeping up with the language!

https://zenn.dev/inuinu/articles/where-is-csharp-used-2026

What Standard C# Guides Don't Teach

When Searching, Use "dotnet", "csharp", or "csharp lang" Instead of "C#"

  • The symbol is stripped out, making it hard to find relevant results!
  • If you include symbols, you might get music-related results instead.
    • Confusion with "cord" or "chord".
  • Also, note that ".NET" is not easily searchable.

C# Taught by AI Is Often Outdated

  • AI (like ChatGPT or Copilot) teaches common ways of doing things.
    • This means it will present common mistakes that everyone makes as the correct answer.
  • It cannot keep up with the latest C# updates, resulting in an outdated style.
    • Like a middle-aged person trying too hard to use trendy slang that they don't fully understand.
    • If you're going to learn, you might as well learn the new stuff.

https://zenn.dev/inuinu/articles/c60abf13d5f47a#aiが教えてくれないことも教えてくれる!

If you must use AI...

"AI-kun, why do you forget what I told you about memory so quickly?"

Even if you instruct it to write in the latest C#, it might be fine at first, but it will gradually start forgetting. Also, sometimes it doesn't really understand what the "latest" actually is, leading it to output outdated syntax.

If you have a system where you can constantly enforce instructions (like GitHub Copilot), it is better to be very specific, as shown below.

Example: copilot-instructions.md
# Instructions for C# code generation
- Follow these instructions when generating C# code:
- Use the latest C# syntax.
- Always follow these rules if possible:
    - File-scoped namespace declarations.
    - Use of collection expressions.
    - Use pattern matching instead of casting or 'as'.

Use the English Version of Official API References

https://learn.microsoft.com/en-us/dotnet/api/

Tips for Using the Official Manual (MS Learn)

API Reference

  • Check if the version at the top left is set to the latest .NET version.
  • Press the globe icon at the top right to switch to the English version.
  • Verify that the language next to the globe icon is set to "C#".
    • If it's set to another language, the sample code will be displayed in that language.

Tools to Use for Learning C#

  • My personal minimum requirements:
    • Code completion support
    • Language server integration
    • Debugger integration

Potential Pitfalls

Difference Between "C#" and ".NET"

  • These two are often explained interchangeably, which is confusing!

  • C#

    • Refers to the programming language itself.
    • It is completely different from "C" or "C++."
  • .NET

    1. The API available for use in C#.
    2. The runtime that executes C#.
    3. The environment that combines the above two with peripheral technologies (in a broad sense).

Differences in ".NET Something"

  • ".NET"
    • The current official runtime/SDK.
    • The latest version at the time of writing is .NET 8.0.
    • Often used in the broad sense mentioned above.
  • ".NET Framework"
    • An older, Windows-only runtime/SDK.
    • Beginners should not use this.
    • The final versions are in the .NET Framework 4.8 line.
    • Do not refer to tutorials or people who use this term.
  • ".NET Core"
    • An older version of the current ".NET" (the name changed halfway through).
    • Support has ended; do not use this anymore.

You Can Build for Old Runtimes Using New SDKs

  • You don't have to use an old environment just because you are targeting an old platform.
    • You don't need to follow outdated tutorials.
    • Old environments (.NET Framework) are completely different from current ones (.NET), making it painful to stick to them unnecessarily.
  • You can write for old environments using the latest C# syntax.
    • No need to use inefficient old ways of writing code.

→ Configure output for old environments using the latest SDK

Lies Often Seen in Introductory Articles

[Lie] "Windows Only"

  • It is a lie that it is Windows-only!
  • It is naturally multi-platform by default!
    • Articles that claim this are referring to the old ".NET Framework."
  • Mentions of "Mono this..." or "Unity that..." are also outdated!

[Lie] "Use .NET Framework"

→ Differences in ".NET Something"

  • The name of the C# runtime and SDK is no longer ".NET Framework"!
  • It is now simply called ".NET."
  • While ".NET Framework" can still be used, there is no reason for a beginner to use it.
  • This name remains in an incredible number of introductory articles and videos...
    • It actually serves as a landmark for outdated content.

[Lie] "C# uses JIT compilation"

  • C# can perform native compilation!
    • It is called NativeAOT.
  • You can choose whether to use JIT compilation or native compilation when building.
  • However, there are limitations, so you cannot simply make everything native.

https://zenn.dev/inuinu/articles/csharp-native-aot

[Lie] "C# apps won't run without a runtime installed"

  • You can run C# apps exactly as you built them.
  • You can also make them smaller for environments where a runtime is pre-installed.
    • In that case, the app won't run without the runtime.
  • It is a trap that this is the default if you don't configure anything...
.NET Runtime Size Restrictions
Native Compilation (NativeAOT) Not Required Small Many
JIT Compilation Not Required Large Few
JIT Compilation
(Runtime Required)
Required Small Few

[Lie] Compile with csc

  • It is a lie that you use csc to compile C#.
    • (No one) runs this command directly anymore.
  • You either build with Visual Studio or use the dotnet CLI.
  • You compile using subcommands of the dotnet command:
    • dotnet build
    • dotnet publish
    • dotnet test

[Lie] Hello World

If you see a "Hello World" like this in C#, it is a total lie now.

A big lie of a Hello World
using System;

namespace Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

This is what a Hello World in modern C# looks like.

Console.WriteLine("Hello World!");
  • Why make people write so much redundant code when it can be done in one line...?
    • Is all that boilerplate really necessary?
    • Beginners will end up hating it, right?
    • Since it works, there's also the trap of not realizing it's bad practice.

Surprisingly, even the official manual's tutorials were bad.
Correction: They have finally been updated!

https://learn.microsoft.com/ja-jp/dotnet/csharp/tour-of-csharp/

However, the template created by dotnet new console is properly reduced to one line.

dotnet new console
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

Introductory Articles I Wish Existed

Recommend editors other than Visual Studio

  • I want articles to teach cross-platform editors like VS Code and Rider.
    • Since C# is a cross-platform language, the editors should be too!
  • Please stop writing articles that assume VS...
  • Since everyone is using VS Code, it would be great to have articles that assume VS Code.

Teach how to install the latest .NET SDK

  • Properly teach how to install the latest SDK.
  • Do not mention ".NET Framework" (except to explain what it is).

Teach and enable code analyzers

  • This is something beginners should be taught above all else.

Teach using the latest, minimal code samples

  • Global using and top-level statements that don't require boilerplate.
  • The namespace A; syntax that reduces indentation.
  • Teach using the latest syntax that is beginner-friendly and reduces typing.
Code like this
Console.WriteLine("Hello, World!");

Clearly identify old syntax as old

  • Don't just leave it; distinguish it as an older way of writing.
  • Teach that prohibited writing styles or APIs should "not be used."

Teach how to use the dotnet CLI

  • The dotnet CLI is a unified tool where other languages might have fragmented or unofficial tools.
  • This is one of the reasons why I think C# is for programming beginners, so please teach it properly.

dotnet new

  • Don't just copy-paste or type character by character; teach how to use templates.
    • dotnet new
  • Teach that you can create useful files other than C#.
    • dotnet new gitignore to create .gitignore
    • dotnet new editorconfig to create .editorconfig

dotnet sln

  • Teach the difference between solutions and projects.

dotnet run / build / publish

  • Explain the differences between compiling and executing, compiling, and building.
  • Teach how to do cross-compilation.
  • Teach how to choose between JIT (with runtime), and Native Build (NativeAOT).

dotnet add / remove

  • Teach how to introduce libraries from nuget.org.
  • Use dotnet add commands instead of direct downloads or NuGet commands.

Teach purpose-specific introductions and research methods

  • C# is a language where you can do "anything reasonably well."
    • It's not always the best, but it can be a better choice.
  • Therefore, it can be used for various purposes.
  • Teach simple introductions or research methods for different purposes.
    • Maybe try to avoid teaching obsolete official frameworks, etc...

Summary

  • Characteristics of C#:
    • Rapid changes: Annual major updates introduce new styles and syntax.
    • Compatibility: Code from 20 years ago still runs, but information update lag is a problem.
  • Credibility of Information:
    • Introductory articles and videos are not always reliable. Check official information based on the C# version!
    • There are many people saying different things, which tends to cause confusion.
  • Search and Official Information:
    • I recommend using "dotnet," "csharp," or "csharp lang" instead of "C#" when searching!
    • The official API reference is better in English.
  • C# Differences:
    • The difference between C# and .NET.
    • The difference between the old .NET Framework, .NET Core, and the latest .NET.
    • You should use the latest .NET.
  • Lies and Misunderstandings:
    • Introductory articles and videos often contain old and incorrect information!
    • Misinformation like "Windows only" or the old ".NET Framework."
  • Compilation and Editors:
    • Using the csc command or excessive "Hello World" examples is bad!
    • Recommended editors and how to install the latest SDK.
  • Use of dotnet CLI:
    • I want to know how to use the dotnet command and its useful functions!
    • Suggestions for file creation, project management, and adding libraries.
  • Diverse Uses of C#:
    • Since C# can be used reasonably well for various purposes, I wanted an introduction or research method based on the purpose!

Discussion

しゃりしゃり

C# 入門 で検索したところかなり上にこの記事がでてきたので読ませていただきました。
キャッチアップにあたり、注意点として大変参考になりました。ありがとうございます。

一方、「 ウソ」が含まれていたので僭越ながら指摘させていただきます。

なんと、公式のマニュアルのチュートリアルもダメです。

2026年1月現在、公式では1文のHellow Worldがま真っ先に掲載されています。
それに続いて古い方も掲載されていますが、これは以下の通り、C#の入門としてふさわしい基礎が複数含まれているためであり、意図的なようでした。
https://learn.microsoft.com/ja-jp/dotnet/csharp/tour-of-csharp/overview

1行の書き方を記載せずに古めかしい書き方のみをさも正しいと紹介するのは、いぬいぬ様の言葉をお借りすれば「 ウソ」かもしれませんが、公式はそうではないと思いました。

この代替形式は引き続き有効であり、すべての C# プログラムの基本的な概念の多くが含まれています。 多くの既存の C# サンプルでは、次の同等の形式が使用されています。

(コードを省略 )

上記の "Hello, World" プログラムは、using名前空間を参照するSystem ディレクティブで始まります。 名前空間は、C# のプログラムとライブラ…( 後略)

1
いぬいぬいぬいぬ

む!時間が経って公式マニュアルの内容も変わったんですね!
この記事も更新しないと「ウソ」だらけになっちゃいますね、ありがとうございます!

4