AleAle.01 1.0.0

dotnet add package AleAle.01 --version 1.0.0
                    
NuGet\Install-Package AleAle.01 -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AleAle.01" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AleAle.01" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AleAle.01" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AleAle.01 --version 1.0.0
                    
#r "nuget: AleAle.01, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AleAle.01@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AleAle.01&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AleAle.01&version=1.0.0
                    
Install as a Cake Tool

📄 README - Funzione ControllaCodici

📌 Descrizione

La funzione ControllaCodici è un metodo statico in C# che confronta due stringhe (codice1 e codice2) per verificare se sono uguali, ignorando differenze tra maiuscole e minuscole e spazi iniziali/finali.

Se i codici coincidono, restituisce il codice formattato con la prima lettera maiuscola. Se invece sono diversi, restituisce il messaggio "Codici diversi".


⚙️ Funzionamento

La funzione esegue i seguenti passaggi:

  1. Rimozione degli spazi

    • Usa Trim() per eliminare eventuali spazi all'inizio e alla fine delle stringhe.
  2. Confronto case-insensitive

    • Converte entrambe le stringhe in minuscolo (ToLower()) e le confronta.
  3. Formattazione del risultato

    • Se uguali:

      • Trasforma la prima lettera in maiuscolo
      • Mantiene il resto della stringa invariato
    • Se diversi:

      • Restituisce "Codici diversi"

🧩 Codice

public static string ControllaCodici(string codice1, string codice2)
{
    // Tolgo gli spazi all'inizio e alla fine
    codice1 = codice1.Trim();
    codice2 = codice2.Trim();

    // Controllo ignorando maiuscole/minuscole
    if (codice1.ToLower() == codice2.ToLower())
    {
        // Prima lettera maiuscola
        string risultato = codice1.Substring(0, 1).ToUpper() + codice1.Substring(1);
        return risultato;
    }

    return "Codici diversi";
}

▶️ Esempi di utilizzo

Input Output
"abc", "ABC" "Abc"
" test ", "TEST" "Test"
"abc", "def" "Codici diversi"

⚠️ Note

  • La funzione non gestisce valori null → potrebbe generare eccezioni.
  • Se la stringa è vuota (""), Substring(0,1) genera errore.
  • La formattazione considera solo la prima lettera, non l'intera stringa.

🔧 Possibili miglioramenti

  • Gestione di input null
  • Controllo su stringhe vuote
  • Uso di StringComparison.OrdinalIgnoreCase invece di ToLower()
  • Miglior gestione della capitalizzazione (es. ToUpperInvariant)

📚 Requisiti

  • Linguaggio: C#
  • Compatibile con .NET Framework / .NET Core

👤 Autore

Funzione di utilità per confronto stringhe semplice e leggibile.


Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 131 4/1/2026