Thursday 2 June 2016

send simple gmail email in c#

Hi all.. Once agian today I have a small code sample for you..
This code describes how to send an email using c#


MailMessage mail = new MailMessage("you@yourcompany.com","user@domain.com");
SmtpClient client = new SmtpClient();            
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "smtp.gmail.com";

mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);

Wednesday 4 May 2016

Simple Calculator (Visual)

Hi All. This is khuram Nawaz. Today I am going to show you how to build a Calculator. It is recommended that you get the visual studio environment. if you don't understand the code don't be afraid to ask questions by leaving a comment below.

please don't be afraid to ask questions... Open visual studio and give this a try!!!!!!!!!!!!!



using System;
using System.Windows.Forms;
 
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        float num1, ans;
        int count;
 
        private void btnC_Click_1(object sender, EventArgs e)
        {
            textBox1.Clear();
            count = 0; 
        }
 
        private void btnCE_Click(object sender, EventArgs e)
        {
            
            if (num1==0 && textBox1.TextLength>0)
            { 
                num1 = 0; textBox1.Clear();  
            }
            else if (num1 > 0 && textBox1.TextLength > 0)
            { 
                textBox1.Clear();
            }
        
        }
 
        private void btnback_Click(object sender, EventArgs e)
        {
           
            int lenght = textBox1.TextLength-1;
            string text = textBox1.Text;  
            textBox1.Clear();
            for (int i = 0; i < lenght; i++)
                textBox1.Text = textBox1.Text + text[i]; 
        
        }
 
        private void btnminus_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                num1 = float.Parse(textBox1.Text);
                textBox1.Clear();
                textBox1.Focus();
                count = 1;
            }
        }
 
        private void btnone_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 1;
        }
 
        private void bttntwo_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 2;
        }
 
        private void btnthree_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 3;
        }
 
        private void btnplus_Click(object sender, EventArgs e)
        {
            num1 = float.Parse(textBox1.Text);
            textBox1.Clear();
            textBox1.Focus();
            count = 2;
        }
 
        private void btnfour_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 4;
        }
 
        private void btnfive_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 5;
        }
 
        private void btnsix_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 6;
        }
 
        private void btnmultiply_Click(object sender, EventArgs e)
        {
            num1 = float.Parse(textBox1.Text);
            textBox1.Clear();
            textBox1.Focus();
            count = 3;
        }
 
        private void btnseven_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 7;
        }
 
        private void btneight_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 8;
        }
 
        private void btnnine_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 9;
        }
 
        private void btndivide_Click(object sender, EventArgs e)
        {
            num1 = float.Parse(textBox1.Text);
            textBox1.Clear();
            textBox1.Focus();
            count = 4; 
        }
 
        private void btnzero_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 0;
        }
 
        private void btnperiod_Click(object sender, EventArgs e)
        {
            int c = textBox1.TextLength;
            int flag = 0;
            string text = textBox1.Text;
            for (int i = 0; i < c; i++)
            { 
                if (text[i].ToString() == ".") 
                { 
                    flag = 1; break; 
                } 
                else 
                { 
                    flag = 0; 
                } 
            }
            if (flag == 0)
            { 
                textBox1.Text = textBox1.Text + "."; 
            }
        }
 
        private void btnequal_Click(object sender, EventArgs e)
        {
            compute(count);
        }
 
        public void compute(int count)
        {
            switch (count)
            {
                case 1:
                    ans = num1 - float.Parse(textBox1.Text);
                    textBox1.Text = ans.ToString();
                    break;
                case 2:
                    ans = num1 + float.Parse(textBox1.Text);
                    textBox1.Text = ans.ToString();
                    break;
                case 3:
                    ans = num1 * float.Parse(textBox1.Text);
                    textBox1.Text = ans.ToString();
                    break;
                case 4:
                    ans = num1 / float.Parse(textBox1.Text);
                    textBox1.Text = ans.ToString();
                    break;
                default:
                    break;
            }
        }
       
     }
}

Saturday 2 April 2016

What is C#

My first post is about C#.
Look how can you get started.

C# is a simple, modern, general-purpose, object-oriented programming language developed by Microsoft within its .NET initiative led by Anders Hejlsberg. This tutorial will teach you basic C# programming and will also take you through various advanced concepts related to C# programming language.

Prerequisites

C# programming is very much based on C and C++ programming languages, so if you have a basic understanding of C or C++ programming, then it will be fun to learn C#.

Execute C# Online

If you want to execute c# code online, you can visit: http://rextester.com/


Wish you best of luck.
I will post the sample code in next blogs.

Monday 21 December 2015

I am MSP (Microsoft Student Partner).
I can help you in any problem related to c#.
I am professional in software development, Love to help others.

Wednesday 27 August 2014

Programmer

If you want to be a programmer, you can get help from me.
I am a programmer in following languages and can also teach you.

c/c++
c#
php
javascript
xaml + c# for windows 8/8.1 apps
basic

write to me and i will give you links for tutorials.

Overview

My name is KHURAM NAWAZ KHAYAM.
I am a Software Engineer at Mirpur University of Science and Technology (Must) Mirpur Azad Kashmir.
I am a learner and developer in software industry.
I have a company MGoI Soft having Copyrights 2014.
I develop softwares under this company.

MGoI Soft was discovered on 2008 under the supervision Mr. Asad Nawaz ( my elder brother) Software Engineer, Designer and Developer)

As its name MGoISoft, its the abbreviation of Mughal Group of Industries and Softwares.

I have developed many softwares in many languages.
All these software are free of costs.
In this blog, you can find it.

If you want to become a developer, join hands with us.

Welcome

Asslamoalaikum Everyone....
This is my blog.
You will get study related and other stuff here.
Subscribe and get notifications.
Stay up to date with me