Example: Str.ToLower();
⦁ ToUpper() :
Example: Str.ToUpper();
⦁ Length() :
This method gives a string length.
Syntax: String_name.Length;
Example: Str.Length();
➤ There are many methods for manipulation of string are as follows:
1. Contains();
2. EndsWith();
3. IndexOf();
4. Insert();
5. LastIndexOf();
6. Remove();
7. Replace();
8. Split();
9. Trim();
10. StartsWith();
➤ Code / Program:
A) Form and Coding:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawin;
using System.Linq;
using System.Text;
using System.Threading.Task;
using System.Windows.Form;
namespace Experiment3_String_operations
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged_1(object sender, EventArgs e)
{
String entry1 = textBox1.Text;
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
String entry2 = textBox2.Text;
}
private void button1_Click(object sender, EventArgs e)
{
int r = string.Compare(textBox1.Text,textBox2.Text);
if (r == 0)
{
label3.Text = "Equal!!!";
}
else
{
label3.Text = "Not equal!!!";
}
}
private void button2_Click(object sender, EventArgs e)
{
label4.Text = textBox1.Text.ToUpper(); label4.Text = textBox2.Text.ToUpper();
}
private void button3_Click(object sender, EventArgs e)
{
label5.Text = textBox1.Text.ToLower(); label5.Text = textBox2.Text.ToLower();
}
private void button4_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
label4.Text = textBox1.Text.ToUpper(); label5.Text = textBox1.Text.ToLower();
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
label4.Text = textBox2.Text.ToUpper(); label5.Text = textBox2.Text.ToLower();
}
}
Form:
OPEN IMAGE IN NEW TAB FOR BEST RESULT |
➤ Observations / Results:
For A)
OPEN IMAGE IN NEW TAB FOR BEST RESULT |
OPEN IMAGE IN NEW TAB FOR BEST RESULT |
manipulation methods and perform or implement different methods in program.