Last active
September 2, 2025 00:13
-
-
Save pazteddy/dff2b5b39d132a099cc25098a9f787a7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /* | |
| ===================================== | |
| Análisis de Ventas con LINQ y Excepciones | |
| ===================================== | |
| */ | |
| // 🏆 Ejercicio: | |
| // Desarrollar un sistema para analizar las ventas de una empresa usando colecciones y LINQ. | |
| // Tendrás una clase "Sale" con las siguientes propiedades: | |
| // - Product (public) | |
| // - Category (public) | |
| // - Amount (public) | |
| // | |
| // También una lista con 6 ventas ficticias. | |
| // Lo que tendrás que desarrollar es: | |
| // 1. Filtrar y mostrar las ventas con monto superior a 1000. | |
| // 2. Agrupar las ventas por categoría y calcular el total de ventas por categoría. | |
| // 3. Manejar excepciones en caso de errores al procesar los datos. | |
| partial class Program | |
| { | |
| static void SalesAnalysis() | |
| { | |
| List<Sale> sales = new List<Sale> { | |
| new Sale("Laptop", "Electrónica", 1500), | |
| new Sale("Teléfono", "Electrónica", 900), | |
| new Sale("Silla", "Muebles", 1200), | |
| new Sale("Escritorio", "Muebles", 800), | |
| new Sale("Tablet", "Electrónica", 1300), | |
| new Sale("Lámpara", "Iluminación", 400) | |
| }; | |
| } | |
| } | |
| class Sale | |
| { | |
| public string? Product { get; set; } | |
| public string? Category { get; set; } | |
| public double Amount { get; set; } | |
| public Sale(string product, string category, double amount) | |
| { | |
| Product = product; | |
| Category = category; | |
| Amount = amount; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
