アクセシビリティに一貫性がありません。フィールドの型 'type' のアクセシビリティはフィールド 'field' よりも低く設定されています
すべての public コンストラクトで一般公開オブジェクトを返す必要があるため、フィールドの型のアクセシビリティをフィールド自体のアクセシビリティより低くすることはできません。
次の例では CS0052 が生成されます。
// CS0052.cs
public class MyClass2
{
// The following line causes an error because the field, M, is declared
// as public, but the type, MyClass, is private. Therefore the type is
// less accessible than the field.
public MyClass M; // CS0052
private class MyClass
{
}
// One way to resolve the error is to change the accessibility of the type
// to public.
//public class MyClass
// Another solution is to change the accessibility of the field to private.
// private MyClass M;
}
public class MainClass
{
public static void Main()
{
}
}
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。