I have this code:
public static class GenDAO<T> where T : IEntidad // antes static
{
private static List<T> BDenMemoria = new List<T>();
private static int NextId = 1;
public static int Crear(T entidad)
{
entidad.id = NextId++;
BDenMemoria.Add(entidad);
return entidad.id;
}
public static T Buscar(int id)
{
return BDenMemoria.FirstOrDefault(x => x.id == id);
}
public static void Actualizar(T entidad)
{
int indice = BDenMemoria.FindIndex(x => x.id == entidad.id);
if (indice != -1)
BDenMemoria[indice] = entidad;
}
public static void Eliminar(int id)
{
int indice = BDenMemoria.FindIndex(x => x.id == id);
if (indice != -1)
BDenMemoria.RemoveAt(indice);
}
}
It is part of a code for windows forms and I need to access from the main class to the list BDenMemoria that is private and static, to show in a DataGridView the objects that the list has. But I do not know how to access that list from the outside. Thanks!