Добавьте файлы проекта.

This commit is contained in:
zcher
2025-12-14 18:05:36 +03:00
committed by yato
parent 64b6e01512
commit 84abc28e16
7 changed files with 228 additions and 0 deletions

43
StringUtils.cs Normal file
View File

@@ -0,0 +1,43 @@
namespace First_week
{
internal class StringUtils
{
public static bool IsPalindrome(string s)
{
if (string.IsNullOrEmpty(s))
return false;
string cleaned = new string(s.Where(c => char.IsLetterOrDigit(c)).ToArray()).ToLower();
string reversed = new string(cleaned.Reverse().ToArray());
return cleaned == reversed;
}
public static string ReverseWords(string sentence)
{
if (string.IsNullOrEmpty(sentence))
return sentence;
var words = sentence.Split(' ');
var reversedWords = words.Select(word => new string(word.Reverse().ToArray()));
return string.Join(" ", reversedWords);
}
public static string RemovePunctuation(string s)
{
if (string.IsNullOrEmpty(s))
return s;
return new string(s.Where(c => !char.IsPunctuation(c)).ToArray());
}
public static bool IsAlphaNumeric(string s)
{
if (string.IsNullOrEmpty(s))
return false;
return s.All(char.IsLetterOrDigit);
}
}
}