Sending SMS Via Windows Form Application Using any Android Smart Phone 



Source Code 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using GsmComm.GsmCommunication;
using GsmComm.Interfaces;
using GsmComm.PduConverter;
using GsmComm.Server;
using System.IO;
using System.Data.OleDb;
using System.Management;

namespace sms

{

    public partial class Form1 : Form

    {


        public static Int16 Comm_Port = 0;
        public static Int32 Comm_BaudRate = 0;
        public static Int32 Comm_TimeOut = 0;
        public static GsmCommMain comm;
        DataSet dataSet, dataSet1 = new DataSet();

       
        public Form1()

        {

            InitializeComponent();

        }



        private void button1_Click(object sender, EventArgs e)

        {


            string CELL_Number, SMS_Message;


            SmsSubmitPdu pdu1;


            try

            {
                if (comm.IsConnected() == true)

                {

                    if (Cell_Num.Text.ToString() == "")

                    {

                        MessageBox.Show("Kindly Add Cell Number\r\n\nFor Example\n\n+9231234567", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                        return;

                    }

                    else if (SMS_Text.Text.ToString() == "")

                    {

                        MessageBox.Show("Kindly Add Your Message Text", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                        return;

                    }


                    CELL_Number = Cell_Num.Text.ToString();

                    SMS_Message = SMS_Text.Text.ToString();


                    MessageBox.Show("Kindly Your SMS & CELL NUMBER \r\n\nCELL # : " + CELL_Number + "\r\n\nMESSAGE TEXT : "+SMS_Message ,"SMS INFO", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);


                    try

                    {

                        Cursor.Current = Cursors.WaitCursor;


                        pdu1 = new SmsSubmitPdu(SMS_Message, CELL_Number, "");


                        comm.SendMessage(pdu1);


                        Cursor.Current = Cursors.Default;


                        MessageBox.Show("Message SENT", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);


                    }


                    catch (Exception E5)

                    {


                        MessageBox.Show("Error Sending SMS To Destination Address\r\n\n Connection Has Been Terminated !!!\r\n\n", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        comm.Close();

                       // pictureBox3.Image = imageList1.Images[0];

                        button9.Enabled = true;

                        button10.Enabled = false;

                        Single_SMS.Enabled = false;

                      //  button4.Enabled = false;

                       // button7.Enabled = false;

                        dataGridView3.Rows.Clear();

                    


                    }


                    

                }

                else

                {

                    MessageBox.Show("No GSM Phone / Modem Connected", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    return;

                }

            }

            catch (Exception E10)

            {

                MessageBox.Show("CONNECTION ERROR", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);


            }           


        }


        

      



       

        


     


        private void label30_DoubleClick(object sender, EventArgs e)

        {

            MessageBox.Show(":-)\r\n\nLet The SMS Begin...!!!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }

        


        private void button9_Click(object sender, EventArgs e)

        {

            //Setting the column grid for fetched data


            dataGridView3.ColumnCount = 5;

            dataGridView3.Columns[0].Name = "COM Port";

            dataGridView3.Columns[1].Name = "Connected Device";

            dataGridView3.Columns[2].Name = "Max Baud Rate";

            dataGridView3.Columns[3].Name = "Time Out";

            dataGridView3.Columns[4].Name = "Status";

            dataGridView3.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;


            try

            {

                Cursor.Current = Cursors.WaitCursor;


                ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_SerialPort");                                       


                foreach (ManagementObject queryObj in searcher.Get())

                {


                    if (queryObj != null)

                    {

                        object captionObj = queryObj["DESCRIPTION"];

                        object capdeviceid = queryObj["DEVICEID"];

                        object MaxBaudRate = queryObj["MAXBAUDRATE"];

                        object connstatus = queryObj["STATUS"];

                        string timeoutsec = "100";


                            dataGridView3.Rows.Add(capdeviceid, captionObj, MaxBaudRate, timeoutsec, connstatus);



                    }

                }


            }


            catch (Exception e15)

            {

                MessageBox.Show("An error occurred while querying for WMI data: " + e15.Message);

            }


            Cursor.Current = Cursors.Default;

            button9.Enabled = false;

            button10.Enabled = true;



        }

        


        private void dataGridView3_CellClick(object sender, DataGridViewCellEventArgs e)

        {


            DataGridViewCellStyle style = new DataGridViewCellStyle();


            style.Font = new Font(dataGridView3.Font, FontStyle.Bold);            

            style.BackColor = Color.Green;

            style.ForeColor = Color.White;

            


                int i = dataGridView3.CurrentRow.Index;

                


                try

                {

                    Comm_Port =     Convert.ToInt16(dataGridView3.Rows[i].Cells[0].Value.ToString().Substring(3));

                    Comm_BaudRate = Convert.ToInt32(dataGridView3.Rows[i].Cells[2].Value.ToString());

                    Comm_TimeOut =  Convert.ToInt32(dataGridView3.Rows[i].Cells[3].Value.ToString());

                }

                catch (Exception E1)

                {

                  

                    return;

                }


                comm = new GsmCommMain(Comm_Port, Comm_BaudRate, Comm_TimeOut);


                try

                {


                        comm.Open();

                        if (comm.IsConnected())

                        {


                        


                            MessageBox.Show("Connected Successfully To Mobile ", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            dataGridView3.Rows[i].Cells[4].Value = "Connected";

                            dataGridView3.Rows[i].DefaultCellStyle = style;

                            dataGridView3.ClearSelection();

                            Single_SMS.Enabled = true;


                        }


                        try

                        {

                          

                        }

                        catch (Exception e50)

                        {

                            MessageBox.Show("Error Retriving COM Port Phone Information", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        }

                    


                }

                catch (Exception E2)

                {

                    

                    dataGridView3.ClearSelection();


                }

        }



        private void button10_Click_1(object sender, EventArgs e)

        {

            try

            {

                if (!comm.IsConnected())

                {

                    MessageBox.Show("No Phone Connected", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    return;

                }

                else

                {


                    comm.Close();

                 //   pictureBox3.Image = imageList1.Images[0];

                    button9.Enabled = true;

                    button10.Enabled = false;

                    Single_SMS.Enabled = false;

                    //button4.Enabled = false;

                    //button7.Enabled = false;

                    dataGridView3.Rows.Clear();

                   

                   

                    MessageBox.Show("Disconnected Successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);


                }

            }


            catch (Exception No_Conn)

            {


                MessageBox.Show("No Phone Connected!!\r\n\n" + No_Conn, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);


            }

        }

        


        private void Form1_FormClosed(object sender, FormClosedEventArgs e)

        {

            try

            {

                if (comm.IsOpen() == true)

                {                    

                    comm.Close();

                }

            }

            catch (Exception E16)

            {               

                Application.Exit();

            }


            Application.Exit();

        }

        


        private void SMS_Text_TextChanged(object sender, EventArgs e)

        {

           // label4.Text = "Characters Left : "+(160 - SMS_Text.Text.Length).ToString();

        }


        private void panel1_Paint(object sender, PaintEventArgs e)

        {


        }


        private void SMS_Text_Click(object sender, EventArgs e)

        {

            SMS_Text.Text = "";

        }


        private void comboBox1_Click(object sender, EventArgs e)

        {

            comboBox1.DroppedDown = true;

        }


        private void SMS_Text_Click_1(object sender, EventArgs e)

        {

            SMS_Text.Text = "";

        }


        private void button2_Click(object sender, EventArgs e)

        {

            this.Close();

        }


        private void Single_SMS_Click(object sender, EventArgs e)

        {


            string CELL_Number, SMS_Message;


            SmsSubmitPdu pdu1;


            try

            {


                if (comm.IsConnected() == true)

                {

                    if (Cell_Num.Text.ToString() == "")

                    {

                        MessageBox.Show("Kindly Add Cell Number\r\n\nFor Example\n\n+9231234567", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                        return;

                    }

                    else if (SMS_Text.Text.ToString() == "")

                    {

                        MessageBox.Show("Kindly Add Your Message Text", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                        return;

                    }


                    CELL_Number = Cell_Num.Text.ToString();

                    SMS_Message = SMS_Text.Text.ToString();


                   // MessageBox.Show("Kindly Re-Check Your SMS & CELL NUMBER \r\n\nCELL # : " + CELL_Number + "\r\n\nMESSAGE TEXT : " + SMS_Message, "SMS INFO", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);


                    try

                    {

                        Cursor.Current = Cursors.WaitCursor;


                        pdu1 = new SmsSubmitPdu(SMS_Message, CELL_Number, "");


                        comm.SendMessage(pdu1);


                        Cursor.Current = Cursors.Default;


                        MessageBox.Show("Message Sent Successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);


                    }


                    catch (Exception E5)

                    {


                        MessageBox.Show("Error Sending SMS To Destination Address\r\n\n Connection Has Been Terminated !!!\r\n\n", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        comm.Close();

                    

                        button9.Enabled = true;

                        button10.Enabled = false;

                        Single_SMS.Enabled = false;

                      


                    }



                }

                else

                {

                    MessageBox.Show("No GSM Phone / Modem Connected", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    return;

                }

            }

            catch (Exception E10)

            {

                MessageBox.Show("CONNECTION ERROR", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);


            }           


        }


        private void Single_SMS_KeyPress(object sender, KeyPressEventArgs e)

        {

            if (e.KeyChar == (char)Keys.Enter)

            {

                Single_SMS.PerformClick();

              

            }

        }

        }

    }

Sending SMS with C sharp using mobile phone

Sending SMS Via Windows Form Application Using any Android Smart Phone 

Sending SMS with C sharp using mobile phone

Sending SMS with C sharp using mobile phone

Source Code 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using GsmComm.GsmCommunication;
using GsmComm.Interfaces;
using GsmComm.PduConverter;
using GsmComm.Server;
using System.IO;
using System.Data.OleDb;
using System.Management;
namespace Helper
{
    public partial class Form1 : Form
    {

        public static Int16 Comm_Port = 0;
        public static Int32 Comm_BaudRate = 0;
        public static Int32 Comm_TimeOut = 0;
        public static GsmCommMain comm;
        DataSet dataSet, dataSet1 = new DataSet();
        
        public Form1()
        {
            InitializeComponent();
        }


        private void button1_Click(object sender, EventArgs e)
        {

            string CELL_Number, SMS_Message;

            SmsSubmitPdu pdu1;

            try
            {

                if (comm.IsConnected() == true)
                {
                    if (Cell_Num.Text.ToString() == "")
                    {
                        MessageBox.Show("Kindly Add Cell Number\r\n\nFor Example\n\n+9231234567", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    else if (SMS_Text.Text.ToString() == "")
                    {
                        MessageBox.Show("Kindly Add Your Message Text", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    CELL_Number = Cell_Num.Text.ToString();
                    SMS_Message = SMS_Text.Text.ToString();

                    MessageBox.Show("Kindly Re-Check Your SMS & CELL NUMBER \r\n\nCELL # : " + CELL_Number + "\r\n\nMESSAGE TEXT : "+SMS_Message ,"SMS INFO", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

                    try
                    {
                        Cursor.Current = Cursors.WaitCursor;

                        pdu1 = new SmsSubmitPdu(SMS_Message, CELL_Number, "");

                        comm.SendMessage(pdu1);

                        Cursor.Current = Cursors.Default;

                        MessageBox.Show("M E S S A G E - S E N T", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    }

                    catch (Exception E5)
                    {

                        MessageBox.Show("Error Sending SMS To Destination Address\r\n\n Connection Has Been Terminated !!!\r\n\n", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        comm.Close();
                        button9.Enabled = true;
                        button10.Enabled = false;
                        Single_SMS.Enabled = false;
                        dataGridView3.Rows.Clear();

                    }
                    
                }
                else
                {
                    MessageBox.Show("No GSM Phone / Modem Connected", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch (Exception E10)
            {
                MessageBox.Show("CONNECTION ERROR", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }           

        }

        private void Form1_Load(object sender, EventArgs e)
        {            
          
            button10.Enabled = false;
         
        }

        private void label30_DoubleClick(object sender, EventArgs e)
        {
            MessageBox.Show(":-)\r\n\nLet The SMS Begin...!!!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        
        private void button9_Click(object sender, EventArgs e)
        {
            //Setting the column grid for fetched data

            dataGridView3.ColumnCount = 5;
            dataGridView3.Columns[0].Name = "COM Port";
            dataGridView3.Columns[1].Name = "Connected Device";
            dataGridView3.Columns[2].Name = "Max Baud Rate";
            dataGridView3.Columns[3].Name = "Time Out";
            dataGridView3.Columns[4].Name = "Status";
            dataGridView3.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

            try
            {
                Cursor.Current = Cursors.WaitCursor;

                ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_SerialPort");                                       

                foreach (ManagementObject queryObj in searcher.Get())
                {

                    if (queryObj != null)
                    {
                        object captionObj = queryObj["DESCRIPTION"];
                        object capdeviceid = queryObj["DEVICEID"];
                        object MaxBaudRate = queryObj["MAXBAUDRATE"];
                        object connstatus = queryObj["STATUS"];
                        string timeoutsec = "100";
                        dataGridView3.Rows.Add(capdeviceid, captionObj, MaxBaudRate, timeoutsec, connstatus);
                    }
                }

            }

            catch (Exception e15)
            {
                MessageBox.Show("An error occurred while querying for WMI data: " + e15.Message);
            }

            Cursor.Current = Cursors.Default;
            button9.Enabled = false;
            button10.Enabled = true;
        }
        

        private void dataGridView3_CellClick(object sender, DataGridViewCellEventArgs e)
        {

            DataGridViewCellStyle style = new DataGridViewCellStyle();

            style.Font = new Font(dataGridView3.Font, FontStyle.Bold);            
            style.BackColor = Color.Green;
            style.ForeColor = Color.White;
            

                int i = dataGridView3.CurrentRow.Index;
                

                try
                {
                    Comm_Port =     Convert.ToInt16(dataGridView3.Rows[i].Cells[0].Value.ToString().Substring(3));
                    Comm_BaudRate = Convert.ToInt32(dataGridView3.Rows[i].Cells[2].Value.ToString());
                    Comm_TimeOut =  Convert.ToInt32(dataGridView3.Rows[i].Cells[3].Value.ToString());
                }
                catch (Exception E1)
                {
                   // MessageBox.Show("Select a phone Model", "Check COM Port Values", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                comm = new GsmCommMain(Comm_Port, Comm_BaudRate, Comm_TimeOut);

                try
                {

                        comm.Open();
                        if (comm.IsConnected())
                        {

                          //  pictureBox3.Image = imageList1.Images[1];

                            MessageBox.Show("Connected Successfully To Mobile ", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            dataGridView3.Rows[i].Cells[4].Value = "Connected";
                            dataGridView3.Rows[i].DefaultCellStyle = style;
                            dataGridView3.ClearSelection();
                            Single_SMS.Enabled = true;

                        }

                        try
                        {
                            //Phone_Name.Text = comm.IdentifyDevice().Manufacturer.ToUpper().ToString();
                            //Phone_Model.Text = comm.IdentifyDevice().Model.ToUpper().ToString();
                            //Revision_Num.Text = comm.IdentifyDevice().Revision.ToUpper().ToString();
                            //Serial_Num.Text = comm.IdentifyDevice().SerialNumber.ToUpper().ToString();
                        }
                        catch (Exception e50)
                        {
                            MessageBox.Show("Error Retriving COM Port Phone Information", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    

                }
                catch (Exception E2)
                {
                    //MessageBox.Show("Error While Connecting To GSM Phone / Modem", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    dataGridView3.ClearSelection();

                }
        }


        private void button10_Click_1(object sender, EventArgs e)
        {
            try
            {
                if (!comm.IsConnected())
                {
                    MessageBox.Show("No Phone Connected", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                else
                {

                    comm.Close();
                
                    button9.Enabled = true;
                    button10.Enabled = false;
                    Single_SMS.Enabled = false;
                    dataGridView3.Rows.Clear();
                   
                   
                    MessageBox.Show("Disconnected Successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }
            }

            catch (Exception No_Conn)
            {

                MessageBox.Show("No Phone Connected!!\r\n\n" + No_Conn, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            }
        }
        

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            try
            {
                if (comm.IsOpen() == true)
                {                    
                    comm.Close();
                }
            }
            catch (Exception E16)
            {               
                Application.Exit();
            }

            Application.Exit();
        }
        

        private void SMS_Text_TextChanged(object sender, EventArgs e)
        {
           // label4.Text = "Characters Left : "+(160 - SMS_Text.Text.Length).ToString();
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void SMS_Text_Click(object sender, EventArgs e)
        {
            SMS_Text.Text = "";
        }

        private void comboBox1_Click(object sender, EventArgs e)
        {
            comboBox1.DroppedDown = true;
        }

        private void SMS_Text_Click_1(object sender, EventArgs e)
        {
            SMS_Text.Text = "";
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Single_SMS_Click(object sender, EventArgs e)
        {

            string CELL_Number, SMS_Message;

            SmsSubmitPdu pdu1;

            try
            {

                if (comm.IsConnected() == true)
                {
                    if (Cell_Num.Text.ToString() == "")
                    {
                        MessageBox.Show("Kindly Add Cell Number\r\n\nFor Example\n\n+9231234567", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    else if (SMS_Text.Text.ToString() == "")
                    {
                        MessageBox.Show("Kindly Add Your Message Text", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    CELL_Number = Cell_Num.Text.ToString();
                    SMS_Message = SMS_Text.Text.ToString();

                   // MessageBox.Show("Kindly Re-Check Your SMS & CELL NUMBER \r\n\nCELL # : " + CELL_Number + "\r\n\nMESSAGE TEXT : " + SMS_Message, "SMS INFO", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

                    try
                    {
                        Cursor.Current = Cursors.WaitCursor;

                        pdu1 = new SmsSubmitPdu(SMS_Message, CELL_Number, "");

                        comm.SendMessage(pdu1);

                        Cursor.Current = Cursors.Default;

                        MessageBox.Show("Message Sent Successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    }

                    catch (Exception E5)
                    {

                        MessageBox.Show("Error Sending SMS To Destination Address\r\n\n Connection Has Been Terminated !!!\r\n\n", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        comm.Close();
                    
                        button9.Enabled = true;
                        button10.Enabled = false;
                        Single_SMS.Enabled = false;
                      

                    }


                }
                else
                {
                    MessageBox.Show("No GSM Phone / Modem Connected", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            catch (Exception E10)
            {
                MessageBox.Show("CONNECTION ERROR", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }           

        }

        private void Single_SMS_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                Single_SMS.PerformClick();
              
            }
        }
        }
    }

arithmetic operators in c# console application using class


arithmetic operations in C# like Add Subtract Divide and Multiply using a  Class Named Here Math Class. 


arithmetic operators in c# console application using class


Main Program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Classes
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Enter Your First Number = ");
            int x = int.Parse(Console.ReadLine());
            Console.Write("Enter Your 2nd Number = ");
            int y = int.Parse(Console.ReadLine());

            math operation = new math();

            operation.Add(x, y);
            operation.Sub(x, y);
            operation.divide(x, y);
            operation.multi(x, y);

            Console.ReadLine();


        }
    }
}

Math Class With Operations
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Classes
{
    class math
    {
        public int Add(int x, int y)
        {
            Console.WriteLine("The Sum of Your Numbers =" + (x + y));
            return 0;
        }
        
        public int Sub(int x, int y)
        {
            Console.WriteLine("The Differnce of Your Numbers =" + (x-y));
            return 0;
        }

        public int multi(int x, int y)
        {
            Console.WriteLine("The multiplication of Your Numbers =" + (x * y));
            return 0;
        }

        public int divide(int x, int y)
        {
            Console.WriteLine("The Divsion  of Your Numbers =" +(x/y));
            return 0;
        }
        
    
    }
}

C sharp windows clipboard text



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

namespace WindowsFormsApplication8

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)

        {
            String cbtext = textBox1.Text;
            Clipboard.SetText(cbtext);

        }

    }

}


How to get text from windows clipboard in windows form application



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

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

     
              private void button1_Click(object sender, EventArgs e)
     
      {
            String cbtext = Clipboard.GetText();
            label2.Text = cbtext;
           
           
        }
    }
}


csharp Arithmetic operations Via Classes

In c sharp console application we can use all arithmetic operations via classes. first of you have to create a separate class by going to solution explorer right click on project > Add > Class and Name your class i.e Operations. (following is Source code of our  operations.cs class)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
    class operations
    {
        public int add(int x ,int y )
           {
            int sum = x + y;
            Console.Write("Your Sum is = " + sum);
            return 0;
           }

        public int substract(int x, int y)
           {
            int sub=x-y;
            Console.Write("Substraction of Your Numbers = " + sub);
            return 0; 
           }

        public int multiply(int x, int y)
         
        {
             int muliplication = x * y;
             Console.Write("Multiplication of your Numbers = " + muliplication);
             return 0;
        }

        public int divide(int x, int y)
        
        {
            int division = x / y;
            Console.Write ("Division of your Numbers i s= ");
            return 0;
        }
    }
}

First  You to create a  Instance of your Class in main Program.cs in your Project
operations operation =new operations();

the we call the Required Method in our operation class according to user input. see the following full source code of our  main program.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        
        {
            operations operation =new operations();

            Console.Write("Enter Your First Number =");
            int x = int.Parse(Console.ReadLine());
            Console.Write("Enter Your 2nd Number ");
            int y = int.Parse(Console.ReadLine());

            Console.Write("Select Any Operation ");
            Console.WriteLine("1.Add 2.Substract 3.Multiply 4.divide");

            string choice = Console.ReadLine();

            if (choice == "1")
                operation.add(x, y);

            else if (choice == "2")
                operation.substract(x, y);

            else if (choice == "3")
                operation.multiply(x, y);

            else if (choice == "4")
                operation.divide(x, y);

                Console.ReadLine();


        }
    }
}


csharp windows gadget



Using C# you can have your  own Windows 7. Desktop Google Gadget. Now you can  Search any web , image , Android application or even a  You tube Video directly from Your Desktop. In this tutorial we will teach you to build your own Windows 7 Desktop Google Gadget.

 First of all you may notice that above form is border less and if you make your form border less  you  won't  be able to move it after debugging your application. so for this you have to study one of our  Tutorial on  how to move Borderless form.

using System.Diagnostics;
//Design  your form  and then  you have to  following code in  Go button .
private void gobtn_Click_1(object sender, EventArgs e)     
  {
         if (webrbtn.Checked == true)
Process.Start("https://www.google.com.pk/?gws_rd=cr&ei=qHlKUobnMqSN4ATH_4CIBQ#q=" + txt.Replace(" ", "+"));

else if
                (img_rbtn.Checked == true)

Process.Start("https://www.google.com.pk/search?q="+txt+"l&um=1&ie=UTF-8&hl=en&tbm=isch&source=ogsa=Ntab=wi&ei=FnxKUrbqDKbR4QT5z4DQBw#hl=en&q=" + rep + "&tbm=isch&um=1");

else if
               
           (playrbtn.Checked == true)
Process.Start("https://play.google.com/storehl=en&q="+rep+ "&bav=on.2,or.r_cp.r_qf.&bvm=bv.53371865,d.bGE,pv.xjs.s.en_US.i8jRULGL-Ys.O&biw=1280&bih=913&dpr=1&ie=UTF-8&sa=N&tab=i8");


      else if
(youtuberbtn.Checked ==true)

Process.Start("https://www.youtube.com/results?search_query="+rep+"&oq="+rep+"&"gs_l=youtube.3..0l10.711.3520.0.3682.16.10.0.0.0.0.694.3126.3j0j1j5-4.8.0...0.0...1ac.1.11.youtube.kzRdIqQpQ-Y");

}

private void searchtb_KeyDown(object sender, KeyEventArgs e)
    {
       if (e.KeyCode == Keys.Enter)
       {
       gobtn_Click_1((object)sender, (EventArgs)e);
        }
    }

Sending SMS Via Windows Form Application Using any Android Smart Phone  Source Code  using System ; using System . C...