-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (42 loc) · 2.38 KB
/
Copy pathProgram.cs
File metadata and controls
53 lines (42 loc) · 2.38 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
43
44
45
46
47
48
49
50
51
52
53
namespace Stringclass
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("========== Custom StringClass Demo ==========\n");
StringClass text = " Welcome To StringClass Project ";
Console.WriteLine($" Original : \"{text}\"");
Console.WriteLine($" Length : {text.Length}");
Console.WriteLine($" First Character : {text[0]}");
Console.WriteLine($"\n Trim : \"{text.Trim()}\"");
Console.WriteLine($" Reverse : \"{text.Reverse()}\"");
Console.WriteLine($" Replace : \"{text.Replace('o', '0')}\"");
Console.WriteLine($" Substring : \"{text.Substring(2, 7)}\"");
Console.WriteLine($"\n Contains(\"Project\") : {text.Contains("Project")}");
Console.WriteLine($" StartsWith(\" We\") : {text.StartsWith(" We")}");
Console.WriteLine($" EndsWith(\" \") : {text.EndsWith(" ")}");
Console.WriteLine($"\n IndexOf('o') : {text.IndexOf('o')}");
Console.WriteLine($" LastIndexOf('o') : {text.LastIndexOf('o')}");
Console.WriteLine($" CountOccurrences : {text.CountOccurrences('o')}");
Console.WriteLine("\n GetWords");
foreach (var word in text.GetWords())
{
Console.WriteLine($" • {word}");
}
Console.WriteLine("\n IEnumerable Support");
foreach (char c in text)
{
Console.Write(c + " ");
}
Console.WriteLine();
StringClass clone = text.Clone();
Console.WriteLine($"\n Clone : {clone}");
Console.WriteLine($" Equals : {text.Equals(clone)}");
Console.WriteLine($" EqualsIgnoreCase : {text.EqualsIgnoreCase(clone)}");
Console.WriteLine($" CompareTo : {text.CompareTo(clone)}");
Console.WriteLine("\n=============================================");
Console.WriteLine("All tests completed successfully ✔");
}
}
}