0% found this document useful (0 votes)
2 views

class Program

The document is a C# program that defines a class 'Program' with a 'Main' method to create an array of 'ColombianProduct' objects using various constructors. It demonstrates the use of named arguments and tuple elements to store and display product information such as ID, name, unit price, stock, import tax, and department. The program outputs the details of each product in a formatted table to the console.

Uploaded by

Erik Jimenez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

class Program

The document is a C# program that defines a class 'Program' with a 'Main' method to create an array of 'ColombianProduct' objects using various constructors. It demonstrates the use of named arguments and tuple elements to store and display product information such as ID, name, unit price, stock, import tax, and department. The program outputs the details of each product in a formatted table to the console.

Uploaded by

Erik Jimenez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

class Program

static void Main()

int Id = 1;

string Name = "Café";

decimal UnitPrice = 599;

short UnitsInStock = 100;

decimal ImportTax = 25;

string Department = "Nariño";

ColombianProduct[] Products =

new ColombianProduct(),

new ColombianProduct(Id++),

new ColombianProduct(Id++, Name),

new ColombianProduct(Id++, Name, UnitPrice),

new ColombianProduct(Id++, Name, UnitPrice, UnitsInStock),

new ColombianProduct(Id++, Name, UnitPrice, UnitsInStock, ImportTax),

new ColombianProduct(Id++, Name, UnitPrice, UnitsInStock, ImportTax, Department),

new ColombianProduct(200,department:"Antioquia")//Named arguments Se pueden pasar


parámetros por nombre o por posición

};

ColombianProduct Prueba = new ColombianProduct();

Prueba.Test = (Parametro1:"Adiós", Parametro2:56);

System.Console.WriteLine($"{Prueba.Test.Parametro1},
{Prueba.Test.Parametro2}"); // .Parametro1-->elemento nombrado de la tupla

System.Console.WriteLine($"{Prueba.Test.Item1}, {Prueba.Test.Item2}"); //Item--> elemento


que esta en una tupla.
System.Console.WriteLine("Id\tNombre\tPrecio\tExistencia\tImpuesto\tDepartamento");

foreach(ColombianProduct P in Products)

System.Console.Write($"{P.Id}\t{P.Name}\t{P.UnitPrice}\t{P.UnitsInStock}\t\t");

System.Console.WriteLine($"{P.ImportTax}\t\t{P.Department}");

You might also like