Skip to content

Commit

Permalink
Merge branch 'main' into gitauto/issue-#229-a64400f4-5765-49bc-8c25-6…
Browse files Browse the repository at this point in the history
…1f7e15ebdf2
  • Loading branch information
gstraccini[bot] authored Nov 17, 2024
2 parents cbc90fa + e1c08ac commit fe9e73f
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions examples/dotnet/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

namespace ConsoleApp
{
using System;
Expand Down Expand Up @@ -41,8 +42,27 @@ static void Main()
/// </remarks>
private static string GetCompeFromUser()
{
Console.Write("Buscar COMPE (3 dígitos): ");
return Console.ReadLine();
string compe;
do
{
Console.Write("Buscar COMPE (3 dígitos): ");
compe = Console.ReadLine();
} while (!IsValidCompe(compe));

return compe;
}

/// <summary>
/// Validates if the given <paramref name="compe"/> is a valid COMPE code.
/// </summary>
/// <param name="compe">A string representing the COMPE code to validate.</param>
/// <returns>
/// <see langword="true"/> if the <paramref name="compe"/> is exactly 3 characters long
/// and consists only of numeric digits; otherwise, <see langword="false"/>.
/// </returns>
private static bool IsValidCompe(string compe)
{
return compe.Length == 3 && compe.All(char.IsDigit);
}

/// <summary>
Expand Down

0 comments on commit fe9e73f

Please sign in to comment.