Skip to content

Commit b7fd36a

Browse files
Create Practical 1b: Demonstrate string operations.
Demonstrate string operations.
1 parent 5bc4630 commit b7fd36a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
3+
class Program
4+
{
5+
static void Main()
6+
{
7+
string sample = "Hello, C# Programming!";
8+
9+
// String Length
10+
Console.WriteLine("Length of string: " + sample.Length);
11+
12+
// Convert to uppercase
13+
Console.WriteLine("Uppercase: " + sample.ToUpper());
14+
15+
// Convert to lowercase
16+
Console.WriteLine("Lowercase: " + sample.ToLower());
17+
18+
// Substring example
19+
Console.WriteLine("Substring (5, 3): " + sample.Substring(5, 3));
20+
21+
// Concatenation
22+
string anotherString = " Let's code!";
23+
Console.WriteLine("Concatenated string: " + string.Concat(sample, anotherString));
24+
25+
// Replace example
26+
Console.WriteLine("Replace 'C#' with '.NET': " + sample.Replace("C#", ".NET"));
27+
}
28+
}

0 commit comments

Comments
 (0)