From 3d3bf325ec697c0037c6e5b317538c01a233e6aa Mon Sep 17 00:00:00 2001
From: Erick Bueno <101439440+Erick-Bueno@users.noreply.github.com>
Date: Fri, 13 Sep 2024 06:05:30 -0300
Subject: [PATCH] fix: improve readability of c# example code (#510)
---
examples/dotnet/ConsoleApp.csproj | 9 +++------
examples/dotnet/Program.cs | 27 ++++++++++++++-------------
2 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/examples/dotnet/ConsoleApp.csproj b/examples/dotnet/ConsoleApp.csproj
index 29bcce9e..243827fa 100644
--- a/examples/dotnet/ConsoleApp.csproj
+++ b/examples/dotnet/ConsoleApp.csproj
@@ -1,12 +1,9 @@
-
Exe
- net6.0
+ net8.0
-
-
+
-
-
+
\ No newline at end of file
diff --git a/examples/dotnet/Program.cs b/examples/dotnet/Program.cs
index d56e6341..2339dec7 100644
--- a/examples/dotnet/Program.cs
+++ b/examples/dotnet/Program.cs
@@ -7,14 +7,22 @@ namespace ConsoleApp
class Program
{
- private static string fileContent = System.IO.File.ReadAllText("banks.json");
+ private static string fileContent = System.IO.File.ReadAllText("../../data/bancos.json");
private static List banks = Newtonsoft.Json.JsonConvert.DeserializeObject>(
fileContent
);
static void Main()
{
- Console.WriteLine("Hello World!");
+ ShowBanks();
+ var compe = GetCompeFromUser();
+ FilterBanks(compe);
+ }
+ private static string GetCompeFromUser(){
+ Console.Write("Buscar COMPE (3 dígitos): ");
+ return Console.ReadLine();
+ }
+ private static void ShowBanks(){
Console.WriteLine($"Banks: {banks.Count}");
foreach (var bank in banks)
{
@@ -29,13 +37,7 @@ static void Main()
Console.WriteLine($"\tPortabilidade: {bank.SalaryPortability ?? "False"}");
Console.WriteLine($"\tAtualizado em: {bank.DateUpdated}\n");
}
-
- Console.Write("Buscar COMPE (3 dígitos): ");
- var compe = Console.ReadLine();
-
- FilterBanks(compe);
}
-
private static void FilterBanks(string compe)
{
Console.Clear();
@@ -57,12 +59,11 @@ private static void FilterBanks(string compe)
Console.WriteLine($"\tPortabilidade: {bank.SalaryPortability ?? "False"}");
Console.WriteLine($"\tAtualizado em: {bank.DateUpdated} \n");
}
+ return;
}
- else
- {
- Console.WriteLine("Nenhum Resultado Encontrado.");
- }
-
+
+
+ Console.WriteLine("Nenhum Resultado Encontrado.");
Console.Write("1.Listar Todos \t 2.Buscar COMPE: ");
int option = Convert.ToInt32(Console.ReadLine());