本文へスキップ
製品デスクトップツールTASTECAD図面の確認TASTEFILESファイル管理TASTEFTPファイル転送TASTESSHリモートワークスペースTASTEZIP圧縮と展開開発ツールTASTECODERust 統合開発環境TASTESTUDIO統合開発・テスト環境TASTEETLデータ統合(ETL)サーバーTASTEREMOTEリモートデスクトップサーバーTASTEGEO空間情報サーバーTASTEMAILメールワークスペースはじめるダウンロードドキュメント購入すべての製品
マーケットプレイス
ニュース
技術ニュース今日の開発ニュース開発ドキュメントプログラミング言語RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWebフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngularサーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Expressアプリ・デスクトップ フレームワークTauriFlutterReact NativeElectronアルゴリズムアルゴリズムの基礎主要アルゴリズム発展アルゴリズム実務のアルゴリズム
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケースコミュニティガイド
協業技術移転ウェブサイト構築デスクトップアプリ構築リリース・決済パイプライン販売パートナーお問い合わせ
サービスリモートデスクトップインストールパッケージのカスタマイズ
TASTEDEV
製品

デスクトップツール

TASTECAD複雑な図面を、軽やかにひらくTASTEFILES必要なファイルだけを、最速でTASTEFTPファイルが行き交う、いちばん端正な道TASTESSHサーバーとあなたを、より確かにつなぐTASTEZIPより速くまとめ、より安全にひらく

開発ツール

TASTECODERust アプリの編集・ビルド・デバッグ・テストまでひとつのウィンドウでTASTESTUDIO編集からリモートテスト、承認した AI 修正までTASTEETL値を見ながら、データを運ぶ

サーバー

TASTEREMOTE自社サーバーで運用するリモートデスクトップTASTEGEOGeoServer 互換の空間情報サーバーを Rust で作り直しますTASTEMAILメールの主導権を、もう一度自分の手に

はじめる

ダウンロード全製品の最新版ドキュメント各製品の使い方購入サブスクリプション・永久ライセンスすべての製品全製品を一覧で
すべての製品
マーケットプレイスニュース
技術

ニュース

今日の開発ニュース言語・フレームワーク・GitHub・AI の公式発表開発ドキュメント言語・フレームワーク・アルゴリズムのガイド

プログラミング言語

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

フレームワーク

Webフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngular
サーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
アプリ・デスクトップ フレームワークTauriFlutterReact NativeElectron

アルゴリズム

アルゴリズムの基礎計算量解析 · ソート · 探索 · 基本データ構造 · 木構造とヒープ主要アルゴリズムグラフ探索 · 最短経路と最小全域木 · 動的計画法 · 貪欲法 · 分割統治法 · バックトラッキング発展アルゴリズム文字列アルゴリズム · 数学と整数論 · ビット演算 · セグメント木 · Union-Find実務のアルゴリズムコーディング面接対策 · LRUキャッシュ · レート制限 · コンシステントハッシュ法
開発ドキュメントをすべて見る
コミュニティ
プロジェクトビルダーと作品を探す開発ログ決定と試行錯誤プロンプト再利用できる指示AIツールの問題Claude・Codex・Gemini の問題と回避策ショーケース完成した成果コミュニティガイドオープンにつくる方法
協業
技術移転Rust・egui でネイティブアプリを作るウェブサイト構築10言語、アカウント、ドキュメントとダウンロードデスクトップアプリ構築Rust・egui、WebView なしリリース・決済パイプライン署名・MSI・deb・rpm・AppImage・ハッシュ販売パートナー紹介して決済額の30%お問い合わせ構築・提携・投資のご相談
サービス
リモートデスクトップブラウザから自分のパソコンへインストールパッケージのカスタマイズ必要な機能だけ、設定は事前に
購入
JA
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
ログイン
ログイン
TASTEDEV

小さなツールから、より良い開発へ。

support@tastedev.netTASTEDEVを支援
製品製品ラインナップ購入ドキュメントダウンロードマーケットプレイスサポート
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケース
ポリシープライバシーポリシー利用規約サブスクリプション規約返金ポリシーコミュニティガイドライン
アカウントログイン新規登録
訪問者
今日
012345678901234567890123456789012345678901234567890123456789
昨日
012345678901234567890123456789012345678901234567890123456789
累計閲覧
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
商号
GXSOFT
代表者
CHOI YOUNG GU
事業者登録番号
853-44-00368
所在地
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
電話
+82-10-4404-1523
メール
whitecalvin@tastedev.net
個人情報保護責任者
CHOI YOUNG GU

© 2026 TASTEDEV製品情報は検証済みの開発ソースに基づいています。リリース・改善中

C# ドキュメント
C#
Getting Started with CSyntax BasicsTypes and DataProjects and PackagesErrors and TestingKey Concepts: LINQ, Delegates, and Async
ディスカッション

C# ガイド · 2/6

Syntax Basics

この章は現在、英語でのみ提供しています。

This chapter covers the everyday building blocks of C#: variables, methods, control flow, string interpolation, and the namespaces that organize your code. If you have written C, Java, or JavaScript, most of the syntax will feel familiar right away.

Variables and Constants

C# is statically typed, so every variable's type is fixed at compile time. You can spell the type out, or use var and let the compiler infer it from the right-hand side. Either way the type is locked in; var is not a dynamic type.

int count = 10;
double price = 19.99;
string title = "Learning C#";
bool isActive = true;

var total = count * price;      // inferred as double
var names = new List<string>(); // inferred as List<string>

const int MaxRetries = 3;       // compile-time constant
count += 5;                     // variables can be reassigned
// MaxRetries = 4;              // error: constants cannot change

By convention, locals and parameters use camelCase, while methods, properties, types, and constants use PascalCase. Statements end with a semicolon.

Methods

A method declaration lists a return type, a name, and parameters; use void when nothing is returned. When the body is a single expression, the => arrow form keeps it short.

static int Add(int a, int b)
{
    return a + b;
}

static int Square(int x) => x * x;

// optional parameter with a default value
static string Greet(string name, string greeting = "Hello")
    => $"{greeting}, {name}!";

Console.WriteLine(Add(2, 3));                         // 5
Console.WriteLine(Square(4));                         // 16
Console.WriteLine(Greet("Sam"));                      // Hello, Sam!
Console.WriteLine(Greet(greeting: "Hi", name: "Jo")); // named arguments

Methods declared in a top-level statements file become local functions inside the generated entry point. Inside a class, a static method belongs to the type itself, while a method without static belongs to each instance. Methods can also hand back extra values through out parameters; int.TryParse is the classic example.

Control Flow

Conditionals and loops look just like other curly-brace languages. On top of that, C# offers switch expressions and pattern matching for compact branching.

int score = 87;

if (score >= 90)
    Console.WriteLine("A");
else if (score >= 80)
    Console.WriteLine("B");
else
    Console.WriteLine("C or below");

string grade = score switch
{
    >= 90 => "A",
    >= 80 => "B",
    >= 70 => "C",
    _ => "F",
};

for (int i = 0; i < 3; i++)
    Console.WriteLine($"for: {i}");

foreach (var fruit in new[] { "apple", "pear", "plum" })
    Console.WriteLine($"foreach: {fruit}");

int n = 0;
while (n < 3)
{
    n++;
    if (n == 2) continue; // skip to the next iteration
    Console.WriteLine($"while: {n}");
}
この章について質問がありますか?
前の章Getting Started with C次の章Types and Data

The _ arm in a switch expression is the catch-all, and the compiler warns you if some inputs are left unhandled. The is operator matches patterns too: if (value is int number && number > 0) checks the type, converts, and tests the value in one go.

String Interpolation

Prefix a string with $ to embed expressions in braces. A format specifier after a colon controls how numbers and dates are rendered.

var item = "Keyboard";
var unitPrice = 49.90m;
var quantity = 2;

Console.WriteLine($"{quantity} x {item}: {unitPrice * quantity:C}");
Console.WriteLine($"Ratio: {0.256:P1}");          // 25.6%
Console.WriteLine($"|{item,-10}|{quantity,5}|");  // left and right alignment

var path = @"C:\data\report.txt";               // verbatim string: backslashes stay as-is
var json = """
    { "name": "TASTEDEV", "ok": true }
    """;                                         // raw string literal

The m suffix makes a decimal, the right type for money. The C format uses the current culture's currency format, so its output depends on the machine. Raw string literals, delimited by three double quotes, need no escaping for quotes or backslashes, which makes them ideal for embedded JSON or SQL.

Namespaces and using Directives

Namespaces group types so their names don't collide. Writing namespace Name; at the top of a file places every type in that file inside the namespace (a file-scoped namespace). To use types from another namespace, import it with a using directive.

// Models/Order.cs
namespace Shop.Models;

public class Order
{
    public int Id { get; set; }
}
// Program.cs
using System.Text;
using Shop.Models;

var order = new Order { Id = 42 };
var builder = new StringBuilder();
builder.Append("Order number: ").Append(order.Id);
Console.WriteLine(builder.ToString());

With ImplicitUsings enabled you never have to write out namespaces like System, System.Collections.Generic, or System.Linq. To make your own import available project-wide, add a line such as global using Shop.Models; to any one file.

Summary

  • Declare variables with an explicit type or var; either way, the type is fixed at compile time.
  • Methods have a return type, name, and parameters; short bodies use =>, and callers can use optional and named arguments.
  • Beyond if, for, foreach, and while, switch expressions and pattern matching keep branching concise.
  • $"..." interpolation with format specifiers shapes output, and raw string literals hold multi-line text verbatim.
  • File-scoped namespaces group your types, and using brings in types from other namespaces.

コメント 0件

人気のコメント順新しい順

ログイン · ログインするとコメントできます。