Last active
December 25, 2015 05:49
-
-
Save Fhernd/6926854 to your computer and use it in GitHub Desktop.
Demostración de herencia y propiedades 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
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