CKTIS / C#
public: riferimento pratico
public: riferimento pratico: public espone un tipo o membro a ogni consumatore consentito dal tipo contenitore.
Versione: C# language; verified against C# 14 reference
Sintassi
public /* grammar-specific form */public espone un tipo o membro a ogni consumatore consentito dal tipo contenitore.
Usalo solo per una API stabile e documentata.
Ogni membro public aumenta il costo di compatibilità e la superficie di sicurezza.
Un membro public in un tipo internal non è accessibile fuori dall’assembly.
Il programma completo usa realmente public; lo stdout esatto atteso è 6.
Esempi
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
Console.WriteLine(new PublicType().Value);
public sealed class PublicType { public int Value => 6; }
Risultato
6
Il programma completo usa realmente `public`; lo stdout esatto atteso è `6`.