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);
        }
    }

SQlite Login Form Csharp

using Finisar.SQLite;

private void SetConnection()

{

sql_con = new SQLiteConnection("Data Source=test.db;Version=3;New=False;Compress=false;"); 

}
              private void ExecuteQuery(string txtQuery)

        {
            SetConnection();
            sql_con.Open();
            sql_cmd = sql_con.CreateCommand();

            sql_cmd.CommandText = txtQuery;
            sql_cmd.ExecuteNonQuery();

            sql_con.Close();

        }


                 private void LogInBtn(object sender, EventArgs e)
      
       {

           string query = "select from  (UserInfo) where Password='" + textBox1.Text + "'";
            ExecuteQuery(query);
            SQLiteDataReader dr = sql_cmd.ExecuteReader();
            int count = 0;
            string password = "";

while (dr.Read())
            {

                 count++;

            }

            if (count == 1)

            {

               MessageBox.Show("Logged In ");
           }

            else

                          MessageBox.Show("Wrong Password");

      }
    }
}

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