Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Last active December 25, 2015 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/6981370 to your computer and use it in GitHub Desktop.
Save Fhernd/6981370 to your computer and use it in GitHub Desktop.
Demostración del uso de un indizador en C#.
using System;
public class Frase
{
string[] palabras = "GitHub Gist permite crear fragmentos de código de forma eficiente.".Split();
public string this [int indicePalabra] // indexer
{
get
{
return palabras[indicePalabra];
}
set
{
palabras[indicePalabra] = value;
}
}
public static void Main()
{
Frase f = new Frase();
Console.WriteLine (f[1]); // Gist
f[9] = "rápida";
Console.WriteLine (f[9]); // rápida
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment