mirror of
https://github.com/Stone-Red-Code/Stone_Red-C-Sharp-Utilities.git
synced 2026-09-04 00:56:24 +02:00
4.7 KiB
4.7 KiB
Stone_Red-C-Sharp-Utilities
Adds useful C# methods.
Install
Package Manager
Install-Package Stone_Red-C-Sharp-Utilities
.NET CLI
dotnet add package Stone_Red-C-Sharp-Utilities
NuGet
https://www.nuget.org/packages/Stone_Red-C-Sharp-Utilities
Namespaces
Stone_Red_Utilities.ArrListExtentions
Methods:
- Print
- Description: Prints items of array
- Parameters:
this Array array,char delimiter,bool printToDebugConsole - Example usage:
string[] yourArray = { "str1", "str2", "str3" }; yourArray.Print(';'); - Output:
str1; str2; str3
- Print<T>
- Description: Prints items of list
- Parameters:
this List<T> list,char delimiter,bool printToDebugConsole - Example usage:
List<double> yourList = new() { 1.45, 6.24, 4.14 }; yourList.Print(';'); - Output:
1.45; 6.24; 4.14
- PrintTable<T>
- Description: Creates and prints table from 2D array
- Parameters:
this T[,] array,TableStyle tableStyle - Example usage:
int[,] your2dArray = { {1,2,3 }, {4,5,6 }, {7,8,9 } }; your2dArray.PrintTable(TableStyle.Default); - Output:
------------- | 1 | 2 | 3 | ------------- | 4 | 5 | 6 | ------------- | 7 | 8 | 9 | -------------
Stone_Red_Utilities.ColorConsole
Methods:
- Write
- Description: Writes the text representation of the specified object to the standard output stream.
- Parameters:
object value,ConsoleColor color - Example usage:
ConsoleExt.Write("text in red", ConsoleColor.Red); - Output:
(Imagine that the text is actually red)
text in red
- WriteLine
- Description: Writes the text representation of the specified object, followed by the current line terminator, to the standard output stream.
- Parameters:
object value,ConsoleColor color - Example usage:
ConsoleExt.WriteLine("text in green", ConsoleColor.Green); - Output:
(Imagine that the text is actually green)
text in green
Stone_Red_Utilities.BoolExtentions
Methods:
- OneWayTrue
- Description: Sets value to true if input is true. If input is false the value will not change.
- Parameters:
this ref bool bol,bool input - Example usage:
bool bol = false; bol.OneWayTrue(false); Console.WriteLine(bol); bol.OneWayTrue(true); Console.WriteLine(bol); bol.OneWayTrue(false); Console.WriteLine(bol); - Output:
False True True
- OneWayFalse
- Description: Sets value to false if input is false. If input is true the value will not change.
- Parameters:
this ref bool bol,bool input - Example usage:
bool bol = true; bol.OneWayFalse(true); Console.WriteLine(bol); bol.OneWayFalse(false); Console.WriteLine(bol); bol.OneWayFalse(true); Console.WriteLine(bol); - Output:
True False False
Stone_Red_Utilities.StringExtentions
Methods:
- EqualsIgnoreCase
- Description: Determines whether this instance and another specified string object have the same value regardless of upper and lower case.
- Parameters:
this string str,string value - Example usage:
string str1 = "BIG"; string str2 = "big"; bool match = str1.EqualsIgnoreCase(str2); Console.WriteLine(match); - Output:
True
- EqualsIgnoreSpaces
- Description: Determines whether this instance and another specified string object have the same value regardless of spaces.
- Parameters:
this string str,string value - Example usage:
string str1 = "space"; string str2 = " s p a c e "; bool match = str1.EqualsIgnoreSpaces(str2); Console.WriteLine(match); - Output:
True
- EqualsIgnoreSpacesAndCase
- Description: Determines whether this instance and another specified string object have the same value regardless of upper and lower case and spaces.
- Parameters:
this string str,string value - Example usage:
string str1 = "BIG space"; string str2 = "big s p a c e "; bool match = str1.EqualsIgnoreSpacesAndCase(str2); Console.WriteLine(match); - Output:
True