HookJordan Posted April 11, 2017 Author Share Posted April 11, 2017 Welcome to the first entry of my C# programming guides. Through this tutorial I hope to provide you with enough knowledge to begin your adventure with the C# Programming language. I will be going over various entry-level programming topics through this thread and hope they will assist you with either learning the language or migrate to it from another such as VB, java or even C++.Due to the amount of content I wish to cover over the duration of this series, I will be splitting the tutorials into various threads based on content. Once more than one entry to the series has been released I will create a "Master Index" thread with links to all entries in the tutorial.Table of contents1. Introduction to .NET2. Getting Started - Visual Studio3. Hello World1\. IntroductionThe C# programming language is a "high level" programming language built on the .NET framework; a platform provided by Microsoft to assist with rapid application development for Microsoft based platforms. With this being said it is still possible to use the C# programming language to develop for alternative platforms such as UNIX based OS and MAC OS X via the mono framework.Over the years Microsoft (hence forth will be MS), has released various updates to the framework correcting bugs, adding features and updating features. For the purposes of these tutorials I will be providing code relevant for .NET 4.5.2\. Please note that this means some of the code will not be compatible with newer and or older versions of the framework.So what is this framework?Think of the .NET framework as a base for your programs. The framework provides us with numerous built-in features to assist with developing software for Windows base OS. In other words it's going to provide you with a quick way to complete tasks that may not be so quick in other languages. The .NET framework also provides us with other neat and nifty tools such as the JIT debugger, and CLR.JIT; Just in time debugger allows provides an easy way for us to debug our code on the fly.CLR; Common Language Run-time allows our code to be executed on any system with the correct version of the .NET framework.However, when using the .NET frame and programming in C# there is a certain pipeline in which you program will follow in order to execute in which makes it different from a native language such a C++.The section in the spoiler is a little advanced for a beginner. You may attempt to understand it if you'd like or skip-over it and come back to it at another time. It's not important per say however, it does briefly describe how your applications will compile.>! Below is a diagram of the pipeline in which your code will follow in order to execute:>! ![](https://www.codeproject.com/KB/dotnet/DotNetFramework/compilation.jpg)>! It's pretty self explanatory however, for those of you looking at the diagram and thinking what does this mean I'll explain:>! 1) Code => The code in which you wrote for your program.1.5) The compiler converts your C# code to MSIL code.2) MSIL Code => Microsoft Intermediate Language Code; This code can then be executed through the CLR2.5) CLR => Common Language Run-time allows our code to be executed on any system with the correct version of the .NET framework.3) Native Code => The code in which tells the computer what to do. In other words these are lower level instructions in which were interpreted from your C# code.4) Processor => Well we are really low level know and executing in machine code which is way beyond this tutorial series.>! The only parts that are important for us to know about(as beginners) is 1- 2.5 really. In other words our code, the compiler, how our code is stored and then how it executes. **References:**https://msdn.microsoft.com/en-us/library/67ef8sbd.aspx (C# Programming Guide)http://www.mono-project.com (Mono framework)https://msdn.microsoft.com/en-us/library/bb822049(v=vs.110).aspx (.NET Framework Version Guide)2\. Getting Started - Visual StudioBefore we can jump into coding and learning how to use C# to make our life's easier we must first setup our ide; integrated development environment of choice. In this tutorial series we will be using Visual Studio as it provides us with many useful features for debugging and compiling our code.There are different versions of Visual Studio available for you depending on your needs however, assuming we are all personal hobbyist or education oriented the community edition will suit all of our needs just fine. You can access the latest version of the community edition directly on the MS website via the link below:https://www.visualstudio.com/downloads/**WARNING PLEASE ONLY EVER INSTALL VISUAL STUDIO FROM OFFICE MS WEBSITE OTHER SOURCES MAY CONTAIN VIRUS** Once you have downloaded the VS(Visual Studio) installer you will be prompt to select the tools in which you wish to install. You will want to select the Windows development tools sections as well as any Azure sections if you are looking to get into ASP.NET development at some point. Don't worry if you miss something or want to install more later, you can always upgrade.![](https://i.gyazo.com/e9104a8b02cc63d64baee56c029caea2.png)3\. Hello WorldNow that Visual studio has installed you should be ready to begin your software development career. To make sure everything is setup correctly let's create a simple "Hello World" application.To begin, open Visual Studio 2017\. This may take a few moments if this is the first time you've ever ran Visual Studio as it will need to setup the environment for you. Don't worry if it seems like it's not responding it's just busy creating files and setting defaults.Once loaded, along the menu bar at the top please click "File->New->Project" or "Ctrl+Shift+" on your keyboard. This will open the new project dialog in which will provide you with various options depending on the .NET components you installed.For the purpose of this tutorial you will want to find the "Console App (.NET Framework)" template under the "Visual C#" section.It should look something like this:![](https://i.gyazo.com/5a53a5038d4f9c156ec9e309b15a324b.png)You may name it anything you want. I'll be naming mine "Hello World" and storing it under a folders on my D: drive. You can change where the project files are created and stored via the "Browse" button.Once you are ready simply click "OK" and Visual Studio will begin setting up a new project for you.At this point you should be brought to a new tab in Visual Studio in which you should see a bunch of code _automagically_ generated for you. Since this is only a hello world I've posted the code for this project on pastebin.What we want our program to do is simply say "Hello World" on the screen.![]([color][size]https://i.gyazo.com/172326ff02c35fb75b1cfd5b1c1b5a78.png[/size]For this to happen a few things need to be done. [/color][list][*][color]When the program is opened the operating system needs to find code [color]to run -> Main entry-point [/color][/color][*][color][color]The code needs to somehow output a mess[color]age onto the screen for the user[color] -> [color]Command Prompt Window or Console Window in this case [/color][/color][/color][/color][/color][*][color][color][color][color][color]Once the message is output, we [color]would [color]ideally like the window to stay o[color]pen so we can read[color] it -> [color]Pause the program from closing. [/color][/color][/color][/color][/color][/color][/color][/color][/color][/color][/list][color]Something to keep in mind i[color]s that once your program [color]has finis[color]hed [color]executing all of it's code it will close by itself [color]as there is nothing left to do. Thus in our [color]program we are going to stop this from happening so that we may read the message on the screen. [/color][/color][/color][/color][/color][/color][/color][color][color][color][color][color][color][color][color][b]Back to the list...[/b][/color][/color][/color][/color][/color][/color][/color][/color][color][color][color][color][color][color][color][color]The first thing we need to worry about is where our pr[color]ogram is going to start. This is called the ) Link to comment Share on other sites More sharing options...
Marsh Posted April 11, 2017 Share Posted April 11, 2017 Cool tutorial, I like that you included how to get the software. That was one huge annoyance for me when I was trying to learn programming. They were all tutorials on code and I had no idea how to run it.@'HookJordan':> **I forgot to mention that you need to end each line of your code with a semi-colon ';'. This tells the compiler that that line of code is done and anything after it is a separate statement of code. I will go more into this in the next tutorial when we begin C# data types and basic flow of your programs.**This might confuse people however, not every line ends with a semi-colon. Link to comment Share on other sites More sharing options...
HookJordan Posted April 12, 2017 Author Share Posted April 12, 2017 @'Marsh':> Cool tutorial, I like that you included how to get the software. That was one huge annoyance for me when I was trying to learn programming. They were all tutorials on code and I had no idea how to run it.> > @'HookJordan':> > > **I forgot to mention that you need to end each line of your code with a semi-colon ';'. This tells the compiler that that line of code is done and anything after it is a separate statement of code. I will go more into this in the next tutorial when we begin C# data types and basic flow of your programs.**> > This might confuse people however, not every line ends with a semi-colon.This is true.I've revised the sentence to say "each statement", or should I just remove that line altogether and save it for the next tutorial which will be datatypes. Link to comment Share on other sites More sharing options...
Sunku Posted April 12, 2017 Share Posted April 12, 2017 Like to see this kind of contribution! Keep em coming! Link to comment Share on other sites More sharing options...
Gwen Posted April 12, 2017 Share Posted April 12, 2017 I would just say most lines of code require a ; but there are a few exceptions like class or method declarations that we will go over later or something similar… Link to comment Share on other sites More sharing options...
HookJordan Posted May 12, 2017 Author Share Posted May 12, 2017 Sorry for long delay before the second entry to this series comes out. I've recently started a co-op position and just having a little bit of difficulty finding time to work on it at the moment. Fear not however, as I will eventually finish it and continue working on the rest. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now