CaseON 1.1.0
See the version list below for details.
dotnet add package CaseON --version 1.1.0
NuGet\Install-Package CaseON -Version 1.1.0
<PackageReference Include="CaseON" Version="1.1.0" />
paket add CaseON --version 1.1.0
#r "nuget: CaseON, 1.1.0"
// Install CaseON as a Cake Addin #addin nuget:?package=CaseON&version=1.1.0 // Install CaseON as a Cake Tool #tool nuget:?package=CaseON&version=1.1.0
CaseON: A C# String Casing Library
CaseON is a lightweight C# library providing a simple and efficient way to convert strings to various casing styles. It handles different separators and offers robust error handling.
Features
- Multiple Casing Styles: Supports conversion to:
snake_case
kebab-case
PascalCase
camelCase
Sentence case
Title Case
- Robust Input Handling: Throws informative
ArgumentException
s for null or empty/whitespace input strings. Handles strings containing spaces, underscores, and hyphens. - Easy to Use: Simple static methods provide a clean and intuitive API.
- Lightweight: Minimal dependencies, easy to integrate into existing projects.
Usage
Installation: You can easily add CaseON to your project via NuGet. Alternatively, you can directly include the source code in your project.
Basic Example:
using CaseON;
string myString = "This Is A Test String";
string snakeCase = StringFormatter.ToSnakeCase(myString); // Output: this_is_a_test_string
string kebabCase = StringFormatter.ToKebabCase(myString); // Output: this-is-a-test-string
string pascalCase = StringFormatter.ToPascalCase(myString); // Output: ThisIsATestString
string camelCase = StringFormatter.ToCamelCase(myString); // Output: thisIsATestString
string sentenceCase = StringFormatter.ToSentenceCase(myString); // Output: This is a test string
string titleCase = StringFormatter.ToTitleCase(myString); // Output: This Is A Test String
Console.WriteLine($"Snake Case: {snakeCase}");
Console.WriteLine($"Kebab Case: {kebabCase}");
Console.WriteLine($"Pascal Case: {pascalCase}");
Console.WriteLine($"Camel Case: {camelCase}");
Console.WriteLine($"Sentence Case: {sentenceCase}");
Console.WriteLine($"Title Case: {titleCase}");
- Error Handling:
CaseON throws an ArgumentException
if you pass a null or empty/whitespace string to any of its methods. Make sure to handle this exception appropriately in your code:
try
{
string result = StringFormatter.ToSnakeCase(null);
}
catch (ArgumentException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
API Reference
The StringFormatter
class contains the following static methods:
ToSnakeCase(string input)
: Converts a string to snake_case.ToKebabCase(string input)
: Converts a string to kebab-case.ToPascalCase(string input)
: Converts a string to PascalCase.ToCamelCase(string input)
: Converts a string to camelCase.ToSentenceCase(string input)
: Converts a string to Sentence case.ToTitleCase(string input)
: Converts a string to Title Case.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net6.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.
This release introduces CaseON version 1.0.0, a lightweight and efficient C# library for simplifying string casing conversions. It offers a straightforward API to convert strings to various common casing formats, including snake_case, kebab-case, PascalCase, camelCase, Sentence case, and Title Case. The library includes comprehensive error handling for null, empty, and whitespace-only inputs, throwing informative ArgumentExceptions for ease of debugging. Its simple static methods allow for seamless integration into existing projects, and its minimal dependencies ensure optimized performance. This is the initial release, implementing all core casing conversion functionalities. Future plans include potential support for additional casing styles based on user feedback and ongoing performance optimizations. We encourage users to try CaseON and provide feedback to help improve the library.