0% found this document useful (0 votes)
4 views2 pages

String Class

The document provides various examples of string manipulation in C#, including comparing strings, using character arrays, concatenating strings, checking equality, finding indices, extracting substrings, and replacing characters. Each example is encapsulated within a 'Test' class with a 'Main' method demonstrating the functionality. The code snippets illustrate fundamental string operations in a concise manner.

Uploaded by

slsmgmccsit
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

String Class

The document provides various examples of string manipulation in C#, including comparing strings, using character arrays, concatenating strings, checking equality, finding indices, extracting substrings, and replacing characters. Each example is encapsulated within a 'Test' class with a 'Main' method demonstrating the functionality. The code snippets illustrate fundamental string operations in a concise manner.

Uploaded by

slsmgmccsit
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Using String class Console.

WriteLine(c);
}

using System;
C# Compare
class Test
{ using System;
static void Main(string[] args)
{ class Test
string s = "CodesDope"; {
static void Main(string[] args)
[Link](s); {
} string a = "Codes";
} string b = "Dope";

Using Character array int x = [Link](a, b);


int y = [Link](b, a);

using System;
[Link](x);
[Link](y);
class Test
}
{
static void Main(string[] args)
{ C# Equals
char[] charArray = {'C', 'o', 'd', 'e', 's', 'D', 'o', 'p',
'e'}; using System;
String s = new String(charArray);
class Test
[Link](s); {
} static void Main(string[] args)
} {
string a = "Codes";
C# Concat string b = "Dope";

[Link]([Link](b));
using System;
}
}
class Test
{
static void Main(string[] args) C# IndexOf
{
string a = "Codes"; using System;
string b = "Dope";
class Test
String c = [Link](a, b); {
static void Main(string[] args)

1
{ string b = [Link]('o', 'd');
string a = "CodesDope";
[Link](b);
[Link]([Link]('D')); }
} }
}

C# LastIndexOf

using System;

class Test
{
static void Main(string[] args)
{
string a = "CodesDope";

[Link]([Link]('o'));
}
}

C# Substring
using System;

class Test
{
static void Main(string[] args)
{
string a = "CodesDope";
string b = [Link](5);

[Link](b);
}
}

C# Replace
using System;

class Test
{
static void Main(string[] args)
{
string a = "CodesDope";

You might also like