Friday, October 21, 2011

String Function


Nagpur University MCA V Semester, C#.Net, Embedded System Programming, Nagpur University Practical MCA V SEM



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Practical12_Delegate
{
    public delegate string strDelegate(string s);
    public partial class Form1 : Form
    {
        strDelegate sd;
        public Form1()
        {
            InitializeComponent();
        }

        private void btnUpper_Click(object sender, EventArgs e)
        {
            sd = new strDelegate(DelegateEx.AllChrUpperCase);
            lblStr.Text= sd.Invoke(txtStr.Text);
            lblMsg.Text = "Upper Case . . .";
        }

        private void btnLower_Click(object sender, EventArgs e)
        {
            sd = new strDelegate(DelegateEx.AllChrLowerCase);
            lblStr.Text = sd.Invoke(txtStr.Text);
            lblMsg.Text = "Lower Case . . .";
        }

        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            sd = new strDelegate(DelegateEx.Encrypt);
            lblStr.Text = sd.Invoke(txtStr.Text);
            lblMsg.Text = "Encrypted string . . .";
        }

        private void btnReverse_Click(object sender, EventArgs e)
        {
            sd = new strDelegate(DelegateEx.StrReverse);
            lblStr.Text = sd.Invoke(txtStr.Text);
            lblMsg.Text = "Reverse string . . .";
        }

        private void btnRemSpace_Click(object sender, EventArgs e)
        {
            sd = new strDelegate(DelegateEx.StrRemoveSpace);
            lblStr.Text = sd.Invoke(txtStr.Text);
            lblMsg.Text = "After removing space . . .";
        }      
    }
    class DelegateEx
    {       
        public static string AllChrUpperCase(string s)
        {
            string upper = s.ToUpper();
            return upper;
        }
        public static string AllChrLowerCase(string s)
        {
            string lower = s.ToLower();
            return lower;
        }
        public static string StrReverse(string s)
        {
            int len = s.Length;
            char[] arr = new char[len];
            for (int i = 0; i < len; i++)
            {
                arr[i] = s[len - 1 - i];
            }
            return new string(arr);
        }
        public static string Encrypt(string s)
        {
            int len=s.Length,i=0;
            char[] str = new char[len];
            string str1 = " ";
            while (i < len)
            {
                if(String.Compare( s[i].ToString(),str1)!=0)
                    str[i]=Convert.ToChar(Convert.ToInt32(s[i]) + 100);
                else
                    str[i]= ' ';
                i++;
            }
            return new string(str);
        }
        public static string StrRemoveSpace(string s)
        {
            int len = s.Length, i = 0,j=0;
            char[] str = new char[len];
            string str1 = " ";
            while (i < len)
            {
                //str[i] = ' ';
                if (String.Compare(s[i].ToString(), str1) != 0)
                { str[j] = s[i]; j++; }
                i++;
            }
            return new string(str);
        }
    }
}

Nagpur University MCA V Semester, C#.Net, Embedded System Programming, Nagpur University Practical MCA V SEM

Write the program for the Check-Box demonstration.


Write the program for the Check-Box demonstration.
Nagpur University MCA V Semester, C#.Net, Embedded System Programming, Nagpur University Practical MCA V SEM

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace checkbox_10
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void TXTCHK_ParentChanged(object sender, EventArgs e)
        {

        }

        private void BTNOK_Click(object sender, EventArgs e)
        {
            if (checkBox1.Checked == true)
            {
                TXTCHK.Text = TXTCHK.Text +" "+ checkBox1.Text;
            }
            if (checkBox2.Checked == true)
            {
                TXTCHK.Text = TXTCHK.Text + " " + checkBox2.Text;
            }
            if (checkBox3.Checked == true)
            {
                TXTCHK.Text = TXTCHK.Text + " " + checkBox3.Text;
            }
            if (checkBox4.Checked == true)
            {
                TXTCHK.Text = TXTCHK.Text + " " + checkBox4.Text;
            }
            if (checkBox5.Checked == true)
            {
                TXTCHK.Text = TXTCHK.Text + " " + checkBox5.Text;
            }
        }
    }
}



Write the program for the Check-Box demonstration.
Nagpur University MCA V Semester, C#.Net, Embedded System Programming, Nagpur University Practical MCA V SEM 




Write the program for the Check-Box demonstration.
Nagpur University MCA V Semester, C#.Net, Embedded System Programming, Nagpur University Practical MCA V SEM



Popular 5 Posts Last 7 days