STRING MANIPULATIONS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
{
string str = "Clone() Test";
MessageBox.Show(str);
//string clonedString = null;
//clonedString = (String)str.Clone();
//MessageBox.Show(clonedString);
}
}
private void button2_Click(object sender, EventArgs e)
{
string str1 = null;
string str2 = null;
str1 = "csharp";
str2 = "CSharp";
int result = 0;
result = string.Compare(str1, str2);
MessageBox.Show(result.ToString());
result = string.Compare(str1, str2, true);
MessageBox.Show(result.ToString());
}
private void button3_Click(object sender, EventArgs e)
{
string s1 = "concate";
string s2 = "string";
MessageBox.Show(string.Concat(s1,s2));
}
private void button4_Click(object sender, EventArgs e)
{
string str = null;
str = "CSharp TOP 10 BOOKS";
if (str.Contains("TOPf") == true)
{
MessageBox.Show("The string Contains() 'TOP' ");
}
else
{
MessageBox.Show("The String does not Contains() 'TOP'");
}
}
private void button5_Click(object sender, EventArgs e)
{
string s1 = "bharti";
string s2 = string.Copy(s1);
MessageBox.Show(s2);
button5.BackColor=Color.Red;
button5.Text = "X";
}
private void button6_Click(object sender, EventArgs e)
{
string str1 = "CopyTo() sample";
char[] chrs = new char[6];
str1.CopyTo(0, chrs, 0, 8);
MessageBox.Show(chrs[0].ToString() + chrs[1].ToString() + chrs[2].ToString() + chrs[3].ToString() + chrs[4].ToString() + chrs[5].ToString());
}
private void button7_Click(object sender, EventArgs e)
{
double dNum = 10;
dNum = 32.123456789;
MessageBox.Show("Formated String " + string.Format("{0:n4}", dNum));
}
private void Form1_Load(object sender, EventArgs e)
{
//Form1.DefaultBackColor = Color.Red;
}
private void button8_Click(object sender, EventArgs e)
{
//string st = " hi this is bhartijiledar";
//if (st.Contains("bhartijiledar") == true)
//{
// MessageBox.Show(" the string conatinbharti");
//}
//else
//{
// MessageBox.Show("string does not contains bharti");
//}
//{
//}
// string str = new string();
//
//string st = "hello11";
//string s = string.Format(st);
//MessageBox.Show(s);
//string str = "Hello1";
//int res = string.Compare(st, str);
//MessageBox.Show(res.ToString());
// MessageBox.Show(str.CompareTo(st,str).ToString());
double dno = 12.2341906666;
MessageBox.Show("the string formate is="+string.Format("{0:n6}",dno));
}
}
}