[C#.NET] - Beginning in C# Language

Discussion in 'Mixed Languages' started by Josh Cell, Jul 21, 2011.

  1. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,515
    7,170
    120
    #1 Josh Cell, Jul 21, 2011
    Last edited by a moderator: Apr 20, 2017
    [​IMG]

    Welcome to C# Tutorial for beginners, I'm willing to help your questions!​

    Introduction

    C# is .NET language, need frameworks to work, on compilation, you can select the version that will work, first hand, you need a compiler, in this case, the best is to use Visual C# Express or Visual Studio;

    What the differences?

    Visual C# Express compile C# App's only, is free, Visual Studio compile all .NET languages, isn't free;

    Downloads:

    http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express

    Starting Work

    First Application

    Open the compiler, click on File -> New -> Project;

    [​IMG]

    Select the language, and sub-select Windows Forms Application, change framework to compile, select folder and name project, click in ok;

    [​IMG]

    Done! This is a new project;

    [​IMG]

    On right-down of the compiler, we can set the project proprieties;

    [​IMG]

    On left-side, have a Toolbox, Where we can insert new objects to the program;


    Programming

    I've created a example, it contains:

    I've setted labels, to customize, and named this:

    [​IMG]

    This is a code:​
    Code:
    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 Example
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                textBox1.Text = "Hello MDL!!!";
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                textBox1.ResetText();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
        }
    }
    Explanation

    Code:
    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;
    Functions to use in your code, it's like databases, which allows more commands to apply the code;

    Code:
    namespace Example
    {
        public partial class Form1 : Form
        {
    Namespace and class, which allows you to add new internal functions;

    Code:
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                textBox1.Text = "Hello MDL!!!";
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                textBox1.ResetText();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
        }
    Main functions, this will give life to the application, each function is a thread for each object of the Form;

    Code:
            public Form1()
            {
                InitializeComponent();
            }
    This is function will load the Form to open;

    Code:
            private void button1_Click(object sender, EventArgs e)
            {
                textBox1.Text = "Hello MDL!!!";
            }
    It's a function of button1, named of "Click to Hello!", it will simply change the text of textbox1

    Code:
            private void button2_Click(object sender, EventArgs e)
            {
                textBox1.ResetText();
            }
    It's a function of button2, named of "Clean", it will simply clean the text of textbox1 reseting it;

    Code:
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
    This is a Formload, We can add code before it will start the program;

    _____________________________________________________________________________________________________________

    Simple example, have two actions, that are changing the text of the text box and clean it;

    To learn how everything works, just look at each object, and try to insert attributes to compile your program;

    Example download: http://www.datafilehost.com/download-137174e9.html

    Regards, Josh Cell.



    You like? Worked for you?, Then press thanks button on this post!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. shani0610

    shani0610 MDL Novice

    Mar 29, 2010
    2
    0
    0
    More twicked:
    In properties, find following and change the value to :
    1. start position :centrescreen

    2. minimizebox :false

    3.maximisebox :false

    topmost :true

    these are not major tweaks but they create an "effect". try them.