Propiedades c# en google aparecen las propiedades en el MSDN.
Como acuerdo cuando algo sea privato e interno comenzaremos a escribirlo con guión bajo ( _ ).
Las propiedades pueden ser normalmente lectura, lectura/escritura.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MiPrimeraClase
{
class Program
{
static void Main(string[] args)
{
CPunto miPunto; //aqui declaramos la variable
miPunto = new CPunto();// aqui instanciamos (creación del objeto)
miPunto.posicionX = 3;
miPunto.posicionY = 4;
Console.WriteLine("{0},{1}",
miPunto.posicionX,
miPunto.posicionY);
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MiPrimeraClase
{
public class CPunto
{
//ESTADO INTERNO
int _x;
int _y;
//PROPIEDADES
public int posicionX
{
get
{
return _x;
}
set
{
if (value >= 0 && value <= 100)
{
_x = value;
}
}
}
public int posicionY
{
get
{
return _y;
}
set
{
if (value >= 0 && value <= 100)
{
_y = value;
}
}
}
}
}
DEFINICIÓN DE CLASE CPersona: