Skip to content

Commit 03febdd

Browse files
JaBistDuNarrischJaBistDuNarrisch
authored andcommitted
Added Contains compatible with old .NET version
1 parent 5c95ede commit 03febdd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
3+
namespace DotNetProjects.Migrator.Framework.Extensions;
4+
5+
public static class LinqExtensions
6+
{
7+
/// <summary>
8+
/// Is equal to the Contains method in .NET 9. Please remove it after .NET upgrade.
9+
/// </summary>
10+
/// <param name="source"></param>
11+
/// <param name="toBeChecked"></param>
12+
/// <param name="stringComparison"></param>
13+
/// <returns></returns>
14+
public static bool Contains(this string source, string toBeChecked, StringComparison stringComparison)
15+
{
16+
return source?.IndexOf(toBeChecked, stringComparison) >= 0;
17+
}
18+
}

0 commit comments

Comments
 (0)