Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Last active December 25, 2015 05:49
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/6926854 to your computer and use it in GitHub Desktop.
Save Fhernd/6926854 to your computer and use it in GitHub Desktop.
Demostración de herencia y propiedades en C#.
using System;
public abstract class Figura
{
private string idFigura;
public Figura (string idFigura)
{
IdFigura = idFigura; // asigna el valor de idFigura a la propiedad IdFigura
}
public string IdFigura
{
get
{
return idFigura;
}
set
{
idFigura = value;
}
}
// La propiedad Area es de sólo-lectura
public abstract double Area
{
get;
}
public override string ToString ()
{
return IdFigura + " Área = " + string.Format("{0:F2}", Area);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment