Tag: C#-10.0
Estoy utilizando VS2022, .NET 6, C# 10, con el contexto de nulabilidad habilitado en todo el proyecto. public static ModelEnumerationAttributeProperty FromPropertyInfo(PropertyInfo propertyInfo, object value) { var property = ModelEnumerationAttributeProperty.FromPropertyInfo(propertyInfo); property.PropertyValue = value; property.PropertyValueString = value?.ToString(); return (property); } El tipo auto-detectado de la variable property se resuelve como el tipo . . . Read more
A partir de c# 10.0 se introdujo una nueva forma de declaración de espacio de nombres, también conocido como File-Scoped. Para Visual Studio 2022 todo parece estar bien, pero no para VSCode: Ver la forma antigua de declaración de espacio de nombres y la nueva. Y no depende del tema . . . Read more
¿Existe un consenso dentro de la comunidad de desarrollo de C# sobre el nombre de archivo .cs en el que se declaran las declaraciones de uso global? Iba a adoptar el nombre de archivo GlobalUsings.cs, pero luego descubrí que se crea un archivo oculto llamado MyProject.GlobalUsings.g.cs en segundo plano por . . . Read more
Utilizando C# 10, estoy tratando de convertir un IEnumerable<string>? a un IEnumerable<t>: IEnumerable<string>? inputs = getValues(); if (inputs is null) return false; Type type = typeof(List<>).MakeGenericType(typeof(T)); IList? outputs = (IList?)Activator.CreateInstance(type); TypeConverter converter = TypeDescriptor.GetConverter(typeof(T)); if (converter is null || outputs is null || !converter.CanConvertFrom(typeof(String))) return false; foreach (String input in . . . Read more
¿Es el comportamiento esperado con registros en C#10? Console.WriteLine(new Derived1()); // =salida=> Derived1 { } Console.WriteLine(new Derived2()); // =salida=> Base record Base { public override string ToString() => “Base”; } record Derived1 : Base; record Derived2 : Base { public override string ToString() => base.ToString(); }