I need to use a ArrayList
object object that I have in a class, in one method that I have in another. The files within the project are separate and I have inside one, a function that works on the attributes of the objects within the ArrayList
and I need to pass them to the method.
This I have in a file within a project called Alta de Producto
:
public class AltaDeProducto
{
public static void alta()
{
ArrayList AProducto = new ArrayList();
string respuesta = "si";
...
}
}
In the file called Promociones
, where I have the function, I do not know how to pass the ArrayList
:
public class Promociones
{
public static void descuento( ACA NO SE COMO PASARLE EL ARRAY)
{
foreach(Productos item in desc)
{
Console.WriteLine("Tipo: " + item.tipo);
Console.WriteLine("Marca: " + item.marca);
Console.WriteLine("Talle: " + item.talle);
Console.WriteLine("Precio: " + item.precio);
// Esto es para imprimir lo que el objeto tiene.
}
}
From this file I call the function Promociones
:
public static void mascara()
{
int opcion = 1;
while(opcion!=5)
{
Console.Write("Opcion: ");
opcion = int.Parse(Console.ReadLine());
switch(opcion)
{
case 1:
Console.Clear();
AltaDeProducto.alta();
break;
case 2:
Console.Crear();
Promociones.descuento();
break;
}
}
}