CsharpExtensions Library contains simple and usefull extensions to C#. Table of contents CsharpExtensions Table of contents General info Technologies StringExtensions EnumExtensions Code Examples String extensions ToShort ToInt ToLong ToDouble ToDateTime RemoveWhiteSpaces TransformToEnglishLetters Enum extensions GetDescription GetDescription General info Library contains extensions to C# like stringExtensions, enumExtensions etc. Technologies C# StringExtensions Name Returned type Parameters Description ToShort short? this string value ToInt int? this string value ToLong long? this string value ToDouble double? this string value ToDateTime DateTime? this string value RemoveWhiteSpaces string this string value TransformToEnglishLetters string this string value EnumExtensions Name Returned type Parameters Description GetDescription List< string> this Enum customEnum this Enum customEnum, GetDescription string this string fieldName Code Examples String extensions ToShort var test = "13"; var result = test.ToShort() ?? 0; ToInt var test = "13"; var result = test.ToInt() ?? 0; ToLong var test = "13"; var result = test.ToLong() ?? 0; ToDouble var test = "13"; var result = test.ToDouble() ?? 0; ToDateTime var test = "2019-09-09"; var result = test.ToDateTime(); //possible null RemoveWhiteSpaces t t "t t 222" var test = "test 111 222"; var result = test.RemoveWhiteSpaces(); //result: tes_t111__222 TransformToEnglishLetters var test = "ąębcdęę"; var result = test.TransformToEnglishLetters(); //result: bcd Enum extensions GetDescription var test = new TestEnum(); var result = test.GetDescription(); //result: List<string> {"desc1", "desc2"} public enum TestEnum { [Description("desc1")] Test1 = 1, [Description("desc2")] Test2 = 2 } GetDescription var test = new TestEnum(); var result = test.GetDescription("Test1"); //result: desc1 public enum TestEnum { [Description("desc1")] Test1 = 1, [Description("desc2")] Test2 = 2 }
Enter the password to open this PDF file:
-
-
-
-
-
-
-
-
-
-
-
-