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 ch5_7
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            label3 .Text = "";
            string str1 = textBox1.Text;
            string str2 = textBox2.Text;
            //seach str1 in str2
            int loc = str1.IndexOf(str2);
            if (loc > -1)
                label3.Text += "str2 is in str1 in location : " + loc.ToString();
            else
                label3.Text += "str2 is not in str1";
            label3.Text += "\n";
            //insert str2 into str1 
            str1 = str1.Insert(0, str2);
            label3.Text += "Insert str2 into str1 : " + str1 + "\n";
            //Touper
            str1 = str1.ToUpper();
            label3.Text += "ToUpper str1 : " + str1 + "\n";
            //Compare str1 with str2
            label3 .Text += "Compre str1 with str2 :";
            if(str1.CompareTo (str2) == 0)
                label3 .Text += "str1 = str2";
            else if(str1.CompareTo (str2) > 0)
                label3 .Text += "str1 > str2 ";
            else 
                label3 .Text += "str1 < str2";
            //remove from str1
            label3.Text += "\n";
            if (str2.Length == 0)
                MessageBox.Show("Enter a text in string two:");
            else
            {
                str2 = str2.Remove(0, str2.Length - 2);
                label3.Text += "Remove from str2 : " + str2 + "\n";
            }
            //number format
            label3.Text  += "Print -25 with leading zero : ";
            label3.Text += String.Format("{0 : 0000}", -25);
            label3 .Text += "\n" ;
            label3.Text += "print 245.7548 with two decimal place : ";
            label3.Text += String.Format("{0:00.00}", 245.7548);
        }
    }
}
