Created
July 15, 2015 22:08
-
-
Save Fhernd/62b21ef59a700f87d5dc to your computer and use it in GitHub Desktop.
Demostración del uso de atributos en parámetros opcionales en C#.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OrtizOL - xCSw - http://ortizol.blogspot.com | |
using System; | |
using System.Runtime.CompilerServices; | |
public class AtributosInfoLlamadas | |
{ | |
public static void Main() | |
{ | |
Console.WriteLine(Environment.NewLine); | |
ParametrosConAtributos(); | |
Console.WriteLine(Environment.NewLine); | |
} | |
// Método con parámetros opcionales marcados con atributos: | |
public static void ParametrosConAtributos( | |
[CallerMemberName] string nombreMiembro = null, | |
[CallerFilePath] string rutaArchivo = null, | |
[CallerLineNumber] int numeroLinea = 0) | |
{ | |
Console.WriteLine("Nombre de miembro: {0}", nombreMiembro); | |
Console.WriteLine("Ruta del archivo: {0}", rutaArchivo); | |
Console.WriteLine("Número de línea: {0}", numeroLinea.ToString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment