-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringExtensions.cs
More file actions
42 lines (35 loc) · 1 KB
/
StringExtensions.cs
File metadata and controls
42 lines (35 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.Linq;
namespace MagicCountryResolver
{
public static class StringExtensions
{
public static bool HasAllLetters(this string word, string wordToCompareTo)
{
bool isCandidate = true;
foreach (char character in wordToCompareTo)
{
isCandidate = word.Contains(character);
if (!isCandidate)
break;
}
return isCandidate;
}
public static bool HasAnyLetters(this string word, string wordToCompareTo)
{
bool found = false;
foreach (char character in word)
{
if (found)
continue;
foreach (char inputChar in wordToCompareTo)
{
if (found)
continue;
if (inputChar == character)
found = true;
}
}
return found;
}
}
}