Advertisement
Fhernd

Frase.cs

Nov 14th, 2017
680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1. using System;
  2.  
  3. public class Frase
  4. {
  5.     string[] palabras = "GitHub Gist permite crear fragmentos de código de forma eficiente.".Split();
  6.    
  7.     public string this [int indicePalabra]      // indexer
  8.     {
  9.         get
  10.         {
  11.             return palabras[indicePalabra];
  12.         }
  13.         set
  14.         {
  15.             palabras[indicePalabra] = value;
  16.         }
  17.     }
  18.    
  19.     public static void Main()
  20.     {
  21.         Frase f = new Frase();
  22.         Console.WriteLine (f[1]);       // Gist
  23.         f[9] = "rápida";
  24.         Console.WriteLine (f[9]);       // rápida
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement