Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Parameterless constructor is not a must-provided by user when a struct has a field initializer

クローズ 初心者向け
#56,424 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
88/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
csharp
領域
documentation

調査の方向性

docs/csharp/programming-guide/classes-and-structs/using-constructors.md を開き、フィールド初期化子にはパラメーターなしの struct コンストラクターが必要だという記述を探してください。パラメーター付きコンストラクターが宣言されるとコンパイラーがそのようなコンストラクターを生成することを、提示された例に沿って明確にしてください。記述がこの動作を正確に説明できていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

:watch: Not Triaged dotnet-csharp/svc fundamentals/subsvc
Type of issue

Typo

Description

Dear,

The original description If you declare any field initializers in a struct type, you must supply a parameterless constructor. is not very precise because the following code compiles and runs:


var ss = new SS();
Console.WriteLine(ss.x); // output 0

var sss = new SS(1);
Console.WriteLine(sss.x); // output 1


public struct SS
{
    public int x = 1;
    public SS(int z)
    {
    }
}

The compiler will generates a parameterless constructor when a non-parameterless constructor is provided.

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/using-constructors

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/programming-guide/classes-and-structs/using-constructors.md

Document Version Independent Id

36d0bf3a-29bf-5162-c700-142b03f9a16c

Platform Id

42802e43-5862-c431-46d9-821596208b94

Article author

@BillWagner

Metadata
  • ID: 374a58d4-1905-c664-04b6-fd68e617f8c9
  • PlatformId: 42802e43-5862-c431-46d9-821596208b94
  • Service: dotnet-csharp
  • Sub-service: fundamentals

Related Issues

主要言語
言語のデータがありません
スター
4.8k
フォーク
6.1k
平均マージ
20時間 42分
マージ済み PR(30日)
199

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dotnet/docs のほかの issue

dotnet/docs の issue をすべて見る

似ている issue

Documentation の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。