Post: c# for beginners lesson 2
05-26-2015, 02:05 PM #1
seanjordan
Do a barrel roll!
(adsbygoogle = window.adsbygoogle || []).push({});
This is lesson 2 of your c# programming tutorials. Before i go any further i want to just say while i am providing these tutorials DO NOT EVER copy and paste you will not learn anything by doing this and you will simply be wasting your time.


Recap:
So far we have installed our program and created our first solution;now we can start learning.


Back from where we left of:
Open up Xamarin Studio and open your last created solution. This can be found here:
You must login or register to view this content.
Now you should see something like this:
You must login or register to view this content.

Writing to the console:
Okay so lets start by ignoring everything that is presented currently on Xamarin Studio.
1. I want you to make notes like i have here and take in what i have actually written:
You must login or register to view this content.
2. Okay so now i want you to remove the Console.writeLine ("Hello World!) and type Console.writeLine (); (c# is case sensitive) It should look like this:
You must login or register to view this content.
Note: Okay so you just typed: "Console.writeLine (); Lets analyse this. This whole line is called a function and anything inside the () = (Parameters) is telling the function that you are inputting information for the function. In this case you will be inputting text also known as a STRING(REMEMBER THIS). Also, you want to end your line with ; as this is telling the program you are moving on to your next line of code.

3. Okay so go ahead and enter your string between your parameters for example Console.writeLine ("Hello Sean");
4. Now you want to create a new line underneath this and type Console.ReadKey (); what this does is it tells the console not to close until the user presses any key on the keyboard (On mac you do not need to do this as he console stays open when everything is finished in the console. However, its best to type this anyway incase you goto windows).

You should now end up with something that looks like this:
You must login or register to view this content.


Running your first solution!
Now we can go ahead and press play which is here:
You must login or register to view this content.
You should end up with something like this:
You must login or register to view this content.

Useful Tip(s):

1. Instead of having to write the whole function again like this to create a new line:
You must login or register to view this content.
You can simply write \nThis is a new line after your first line in the current function like this:
You must login or register to view this content.

2. To create notes you can simple use // and your application will not run anything on that line after then 2 slash's for example:
You must login or register to view this content.


Final code:

By the end of this tutorial you should have something like this (DO NOT COPY AND PASTE THIS YOU WONT LEARN):
    using System;

namespace FirstProject
{
class MainClass
{
public static void Main (string[] args) // This is called when the program starts. This is also a Method called "main".
{
Console.WriteLine ("Hello sean.\nThis is a new line without a new function!"); // This simply writes to the console "Hello Wordl!"
Console.ReadKey (); // I CAN MAKE NOTES NOW!
}
}
}


Thats it for this tutorial. If i have made any mistakes please do correct me its appreciated to know if i go wrong. I also have a video here which my tutorials literally follow as i learnt alot from these so feel free to take a look and i will explain anything you dont understand.

The following user thanked seanjordan for this useful post:

Coffee Bean
05-26-2015, 02:09 PM #2
Originally posted by seanjordan View Post
This is lesson 2 of your c# programming tutorials. Before i go any further i want to just say while i am providing these tutorials DO NOT EVER copy and paste you will not learn anything by doing this and you will simply be wasting your time.


Recap:
So far we have installed our program and created our first solution;now we can start learning.


Back from where we left of:
Open up Xamarin Studio and open your last created solution. This can be found here:
You must login or register to view this content.
Now you should see something like this:
You must login or register to view this content.

Writing to the console:
Okay so lets start by ignoring everything that is presented currently on Xamarin Studio.
1. I want you to make notes like i have here and take in what i have actually written:
You must login or register to view this content.
2. Okay so now i want you to remove the Console.writeLine ("Hello World!) and type Console.writeLine (); (c# is case sensitive) It should look like this:
You must login or register to view this content.
Note: Okay so you just typed: "Console.writeLine (); Lets analyse this. This whole line is called a function and anything inside the () = (Parameters) is telling the function that you are inputting information for the function. In this case you will be inputting text also known as a STRING(REMEMBER THIS). Also, you want to end your line with ; as this is telling the program you are moving on to your next line of code.

3. Okay so go ahead and enter your string between your parameters for example Console.writeLine ("Hello Sean");
4. Now you want to create a new line underneath this and type Console.ReadKey (); what this does is it tells the console not to close until the user presses any key on the keyboard (On mac you do not need to do this as he console stays open when everything is finished in the console. However, its best to type this anyway incase you goto windows).

You should now end up with something that looks like this:
You must login or register to view this content.


Running your first solution!
Now we can go ahead and press play which is here:
You must login or register to view this content.
You should end up with something like this:
You must login or register to view this content.

Useful Tip(s):

1. Instead of having to write the whole function again like this to create a new line:
You must login or register to view this content.
You can simply write \nThis is a new line after your first line in the current function like this:
You must login or register to view this content.

2. To create notes you can simple use // and your application will not run anything on that line after then 2 slash's for example:
You must login or register to view this content.


Final code:

By the end of this tutorial you should have something like this (DO NOT COPY AND PASTE THIS YOU WONT LEARN):
    using System;

namespace FirstProject
{
class MainClass
{
public static void Main (string[] args) // This is called when the program starts. This is also a Method called "main".
{
Console.WriteLine ("Hello sean.\nThis is a new line without a new function!"); // This simply writes to the console "Hello Wordl!"
Console.ReadKey (); // I CAN MAKE NOTES NOW!
}
}
}


Thats it for this tutorial. If i have made any mistakes please do correct me its appreciated to know if i go wrong. I also have a video here which my tutorials literally follow as i learnt alot from these so feel free to take a look and i will explain anything you dont understand.



You tutorials are epically coordinated and very well detailed. Well done keep up the good work Happy

The following user thanked Coffee Bean for this useful post:

seanjordan

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo