LFInteractive Docs
  • Programming Documentation
  • C#
    • Installing Visual Studio
    • Understanding C#
      • Namespaces
      • Classes
      • Enum
      • Variables
        • Static Types
        • Primitive Types
        • Access Modifiers
        • Variables vs Properties
        • Nullable Variables
      • Getters and Setters
      • Solution vs Project
      • Struct vs Class
      • Coding Conventions
      • Tasks and Async
        • Parallel Tasks
      • Methods
      • PreProcessor Statements
    • Creating Your First Console App
      • Class Library
        • Models
          • File Model
          • Result Model
        • Controllers
          • File Controller
          • File System Controller
      • Console App
        • Nuget Packages
        • Main Method
    • Minecraft.NET
      • Minecraft.NET Library
      • Modrinth.NET Library
      • CurseForge.NET Library
      • Fabric.NET Library
    • Common Lib
      • Strings
      • Advanced Network Client
      • Advanced Timer
      • Advanced File Info
      • Configuration File
      • Application Config
      • Database File
      • Crypt Class
  • C++
    • Networking
      • Windows Socket (Client)
    • cclip
    • VCPKG
    • spdlog
      • Getting Started
      • Patterns
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. C#
  2. Common Lib

Strings

The Strings class is a part of the Chase CommonLib library developed by LFInteractive LLC. It provides a set of static methods for performing various string-related operations in .NET 6.0 and higher. This documentation will describe the methods available in the Strings class and provide example code snippets for each method.


Methods

GetValidFileName

/// <summary>
/// Gets a valid file name from the original string.
/// </summary>
/// <param name="original">The original string to process.</param>
/// <returns>A valid file name derived from the original string.</returns>
public static string GetValidFileName(string original)

This method takes an original string and removes any characters that are not valid in a file name. It iterates through the characters of the original string and replaces any invalid characters with an empty string. The resulting string is a valid file name that can be used to create files.

Example:

string originalFileName = "my*file?.txt";
string validFileName = Strings.GetValidFileName(originalFileName);
Console.WriteLine(validFileName); // Output: "myfile.txt"

IsAlphaNumeric

/// <summary>
/// Checks if the string is alphanumeric.
/// </summary>
/// <param name="str">The string to check.</param>
/// <returns>True if the string is alphanumeric, false otherwise.</returns>
public static bool IsAlphaNumeric(string str)

This method checks whether a given string consists of only alphanumeric characters (letters and digits). It iterates through the characters of the input string and returns true if all characters are alphanumeric, and false if any non-alphanumeric character is found.

Example:

string alphanumericStr = "abc123";
string nonAlphanumericStr = "abc123!";
bool isAlphanumeric1 = Strings.IsAlphaNumeric(alphanumericStr); // true
bool isAlphanumeric2 = Strings.IsAlphaNumeric(nonAlphanumericStr); // false

IsAlphabetical

/// <summary>
/// Checks if the string is alphabetical.
/// </summary>
/// <param name="str">The string to check.</param>
/// <returns>True if the string is alphabetical, false otherwise.</returns>
public static bool IsAlphabetical(string str)

This method checks whether a given string consists of only alphabetical characters (letters). It iterates through the characters of the input string and returns true if all characters are letters, and false if any non-letter character is found.

Example:

string alphabeticalStr = "abc";
string mixedStr = "abc123";
bool isAlphabetical1 = Strings.IsAlphabetical(alphabeticalStr); // true
bool isAlphabetical2 = Strings.IsAlphabetical(mixedStr); // false

This concludes the documentation for the Strings class in the Chase CommonLib library. You can use the provided methods to perform common string-related operations in your .NET applications.

PreviousCommon LibNextAdvanced Network Client

Last updated 1 year ago

Was this helpful?