-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringService.cs
More file actions
38 lines (26 loc) · 1.06 KB
/
StringService.cs
File metadata and controls
38 lines (26 loc) · 1.06 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
using System;
namespace StringProcessingApp.Services
{
public class StringService
{
private string originalText = string.Empty;
private string currentText = string.Empty;
public void SetText(string text)
{
originalText = text;
currentText = text;
}
public string GetText() => currentText;
public string ToUppercase() => currentText.ToUpper();
public string ToLowercase() => currentText.ToLower();
public int CountCharacters() => currentText.Length;
public bool ContainsWord(string word) => currentText.Contains(word);
public string ReplaceWord(string oldWord, string newWord) =>
currentText.Replace(oldWord, newWord);
public string ExtractSubstring(int startIndex, int length) =>
currentText.Substring(startIndex, length);
public string TrimSpaces() => currentText.Trim();
public void ResetText() => currentText = originalText;
public void UpdateText(string newText) => currentText = newText;
}
}