In this sample console app program, we will do a few things (just as a reminder, I am using Visual Studio)
- take a numerical user input and convert it to an integer
- generate a random number
- take a look at a simple if statement
- and add 2 numbers.

Before we begin, I would like to note that the only instance of math used is addition. However you might want to explore further by substituting the operators. (subtraction (-), multiplication (*) and division(/))

I would also like to note that when doing division, if variabes of int type are used you will not get any remainders (i.e. n.345984) To be able to work with real numbers, numbers with decimals, you can use float. Below is a way to declare a float and assign it a value:

float floatNumber;

floatNumber = 22.34f;

Code:
 
using System;
 
 
 
namespace lessonThree
 
{
 
	 ///<summary>
 
	 /// In this lesson we will cover some basic math
 
	 /// operations, look at an if statement and a few other
 
	 /// useful things that should be understood when
 
	 /// programming in C#
 
	 ///</summary>
 
	 class thirdLesson
 
	 {
 
			///<summary>
 
			/// Ask an age.
 
			/// If under 18 -> Exit Program
 
			/// Give lucky number for the day
 
			/// Predict when person will get rich.
 
			///</summary>
 
			[STAThread]
 
			static void Main(string[] args)
 
			{
 
				 int age;
 
				 //Random object createRand
 
				 Random createRand = new Random();
 
				 int luckyNumber;
 
 
 
				 Console.Write("Enter your age: ");
 
				 //grab the input from user and convert it to
 
				 //an integer, hence the 'Convert.ToInt32();
 
				 age = Convert.ToInt32(Console.ReadLine());
 
 
 
				 //skip line
 
				 Console.WriteLine();
 

 
				 if (age > 17)
 
				 {
 

 
				 //Random generated numbers range from 0 to 1, 
 
				 //therefore we multiply by ten (10) below
 
				 //The .NextDouble() method helps retrieve the value
 
				luckyNumber = (int)(createRand.NextDouble()*10);
 

 
				Console.WriteLine("Your Lucky Number is: {0}", luckyNumber);
 
				//Here you use the value of luckyNumber and add it to his age
 
			 Console.WriteLine("You are {0} years old and will be rich at age: {1}", age, age+luckyNumber);
 
			 //As you can see the zero in braces {0} holds the variable age
 
			 //and the one in braces {1} holds the sum of the variables "age and luckyNumber" age+luckyNumber
 

 
				 }//If the age is not 18 or above we conclude by saying
 

 
				 Console.WriteLine("Thanks and Have a Great Day");
 
				 Console.WriteLine();
 
				 Console.WriteLine("Press [ENTER] to Exit");
 
				 Console.ReadLine();
 
 
 
			}//end Main()
 
	 }//end class
 
}//end namespace 
As you can see this code was commented quite a bit. I will probably do a few more console app lessons and move onto windows apps. In the mean time I hope this is useful to someone.