JTOne123 / Extension

Linq Extension

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

C# Linq + String Extensions

Here is an Linq extension which returns your custom error message in cause of an exception. Linq Implemented: First, Last, Single String Implemented: Left, Right Stopwatch: ToFormatedString

Available for:

  • .NET Standard 2.0
  • .NET Standard 1.5
  • .NET Standard 1.3
  • .NET 4.6.1
  • .NET 4.5

Example Linq:

	List<string> newList = new List<string> {"1234", "987654"};
	newList.SingleOrDefault(x => x == "searchString", "custom error message e.g. search string mot in list");

Example String:

	string testString = "anyTestText";
	var result = testString.Left(4);
	// result == "anyT"
	string testString = "anyTestText";
	var result = testString.Right(4);
	// result == "Text"
	string testString = "Add Additional String";
	var result = testString.ReplaceExactWord("Add", "Insert");
	// result == "Insert Additional String"

Example Stopwatch:

	var result = m_Stopwatch.ToFormatedString("g")
	// result == "0:00:01,5"
	var result = m_Stopwatch.ToFormatedString(@"mm\:ss\.ff")
	// result == "00:01.50"

Example DateTime:

	DateTime result = new DateTime(2019, 1, 22).WeekBeginn();
	// result == new DateTime(2018, 12, 31)
	int result = new DateTime(2016, 2, 22).DaysInMonth()
	// result == 29

Licence:

http://choosealicense.com/licenses/bsd-2-clause/

About

Linq Extension


Languages

Language:C# 100.0%