1. Introduction to C#.NET

“I really like the step-by-step approach”

TalkIT Learning Course

Start Learning Now!

  • Start with this free tutorial in the C# course

  • Learn the easy way in step-by-step stages

  • Getting stuck? Follow an in-depth video

  • Share on your community forum.

 

Exam Preparation

The C# course will help you prepare for these certifications:

  • MTA Developer (Technology Associate) – Software Development Fundamentals Exam 361

  • MCSD/MCSA Universal Windows Platform (Solution Developer) – Programming in C# Exam 483

Overview of this C# Tutorial

Estimated Time – 1 Hour

What is .NET?

    1. .NET is Microsoft's strategic platform for developing enterprise systems for the modern era.
      • ASP.NET Web applications.
      • Mobile applications.
      • Console applications.
    2. .NET recognizes and addresses the traditional difficulties facing application developers.
      • Language interop- VB6, VC6, ASP, WinSDK.
      • Deployment difficulties - DLL's.

What new programming languages are offered in .NET?

      • C# - Similar to Java and C++.
      • Visual Basic - Like VB6 but an Object Orientation approach.
      • C++/CLI - New keywords that allow you to write in C++ for .NET.
      • F# - Functional programming language.
OverView

Why C#?

      • Syntax more like C++ and Java.
      • Syntax very concise.
      • Designed for object orientation - Started with a clean slate, Everything is an object.

The goals behind C#?

    • Simple - Few Keywords.
    • Safe - Find bugs early in development process.
    • Internet Centric - Designed for developing web programs.
    • Hi Performance - Designed for industrial strength programming.

Tutorial 1: Building .NET Applications

  1. Here are some example pieces of code for a Hello World application in C# and VB. First in C#, by creating the hello world application we hope to show you the key foundations of creating an application with the types of user interface in this case a form or a console that will be seen later in the course with their "code behind" files in C# that do all the hard work. using System; public class CSHelloWorld {  public static void Main(string[] args) {   Console.WriteLine("Hello World!");  } }
  2. The second in VB. Imports System Module VBHelloWorld  Public Sub Main(ByVal args As String())   Console.WriteLine("Hello World!")  End Sub End Module
  3. This code can be run from the Visual Studio 2013 command prompt window.
    • Compile the code: csc CSHelloWorld.cs
    • Run the application: CSHelloWorld.exe
  4. What is happening behind the scenes?
      • The .NET Framework provides a set of compilers- csc.exe is the C# compiler, cl.exe is the C++ compiler etc...
      • Each Compiler emits the same bytecode format - IL (Intermediate Language) byte code.   Compiler
    To view the IL you can use IL Disassembler(ildasm.exe). It enables you to view the IL code in a .NET app, this helps you understand how .NET languages work and allows you to write better .NET code. To view the code use the Visual Studio Command prompt. ildasm CSHelloWorld.exe CSHELLOWORLD
  5. Assemblies in .NET.
    • An assembly is a .DLL or .EXE containing managed code E.g. CSHelloWorld.exe.
    • You can create apps that contain (or reference) many different assemblies.
    • To illustrate how assemblies work, we'll build a simple Windows Forms application in C#.
  6. Lab

  7. Start Visual studio 2013 and Start a New project; Choose Visual C# and Windows Form Application.   FormChoice
  8. Drag the bottom right of Form1 to make it larger; and from the left hand side there is a navigation bar that contain a ToolBox Item. Click this, and as you can see there are many different controls that you can access. Drag and drop the control called button (found under common controls) onto Form1, you should see a button on the screen with the writing "button1" inside it.   OverViewApplication
  9. In the bottom right there is a properties table when you select the button, in this properties window set the "Text" attribute to "Click me for hello world". Re-size the button as you wish to make it larger or smaller by selecting and edge and dragging it out or inwards.
  10. To create an event for when the button is clicked, you can double click the button and Visual Studio 2013 will create an event handler for you automatically inside Form1.cs. Inside this handler use this code: MessageBox.Show("Hello World"); OverallResult
  11. View code file.
  12. Now at the top of visual studio 2013 there is a button labelled Start with a green arrow inside it; click this when you want to run/debug your application. So click this and you will see your newly made form appear and when you press the button a message box will appear saying "hello world".
Back to beginning Copyright © 2016 TalkIT®

Well done. You have completed the first tutorial in the C# course.

There are 16 more tutorials in this course. Start the next tutorial now.

Obtain your TalkIT certificate when you finish all the tutorials.

Share on your community forum. Just add a comment below.

If you liked this post, please comment with your suggestions to help others.
If you would like to see more content like this in the future, please fill-in our quick survey.
Scroll to Top