# Session Six: Checkout [toc] ## Validacao e Try ``` csharp= using System; public double AreaRetangulo(double b, double a) { if (b < 0) throw new Exception("Base inválida"); if (a < 0) throw new Exception("Altura inválida"); double area = b * a; return area; } public string PrimeiroNome(string nome) { if (nome == string.Empty) throw new Exception("Nome não pode ser vazio."); string p = nome.Substring(0, nome.IndexOf(" ")); return p; } try { double x = AreaRetangulo(10, 5); string y = PrimeiroNome("Belle Lira"); Console.WriteLine(y); } catch (Exception ex) { Console.WriteLine(ex.Message); } ```` ## Lista ```csharp= using System; using System.Collections.Generic; // criacao - CRUD List<int> lista = new List<int>(); // adicionar lista.Add(130); lista.Add(120); lista.Add(110); lista.Add(100); lista.Add(90); // exibir Console.WriteLine(string.Join(" - ", lista)); // alterar lista[0] = 1; lista[1] = 2; lista[2] = 3; Console.WriteLine(string.Join(" - ", lista)); // ler int x = lista[2]; Console.WriteLine(x); x = lista[4]; Console.WriteLine(x); // remover lista.Remove(1); Console.WriteLine(string.Join(" - ", lista)); lista.RemoveAt(0); Console.WriteLine(string.Join(" - ", lista)); ````
{"metaMigratedAt":"2023-06-16T03:21:34.997Z","metaMigratedFrom":"Content","title":"Session Six: Checkout","breaks":true,"contributors":"[{\"id\":\"49b19583-2153-4cca-9003-e8abd508dfd9\",\"add\":1219,\"del\":0}]"}
Expand menu