Base de conocimientosCentro de exámenes
ESEspañol
Elegir idioma13

CKTIS / C#

namespace: referencia práctica

namespace: referencia práctica: namespace agrupa nombres y evita colisiones sin crear un objeto runtime.

Versión: C# language; verified against C# 14 reference

Sintaxis

namespace /* grammar-specific form */

namespace agrupa nombres y evita colisiones sin crear un objeto runtime.

Úsalo de forma coherente con los límites del dominio y la API public.

Un namespace no es límite de acceso ni módulo de despliegue.

Las formas file-scoped y block-scoped no pueden mezclarse libremente en un archivo.

El programa completo usa realmente namespace; su stdout esperado exacto es 4.

Ejemplos

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 Demo.Value().Number);
namespace Demo { sealed class Value { public int Number => 4; } }

Resultado

4

El programa completo usa realmente `namespace`; su stdout esperado exacto es `4`.

Fuentes