Monday, March 21, 2016

Exercise 4: Variables And Names

Exercise 4: Variables And Names

inspired by  http://learnpythonthehardway.org/book/ex4.html

using System;

public class Test
{
     public static void Main()
     {
           int cars, drivers, cars_not_driven;
           cars = 100;
           drivers = 30;
           cars_not_driven = cars - drivers;
          Console.WriteLine("There will be " + cars_not_driven + " empty cars today.");
     }
}

Exercise 3: Numbers and Math

Exercise 3: Numbers and Math

inspired by  http://learnpythonthehardway.org/book/ex3.html

using System;

public class Test
{
     public static void Main()
     {
          Console.WriteLine("I will now count my chickens:");

          Console.WriteLine("Hens"+ (26 + 30 / 5) );
          Console.WriteLine("Roosters"+ (100 - 25 * 3 % 4) );

          Console.WriteLine("Now I will count the eggs:");

          Console.WriteLine(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6);

          Console.WriteLine("Is it true that 3 + 2 < 5 - 7?");
          Console.WriteLine(3 + 2 < 5 - 7);

          Console.WriteLine("What is 3 + 2? "+ (3 + 2) );
          Console.WriteLine("What is 5 - 7? "+ (5 - 7) );

          Console.WriteLine("Oh, that's why it's False.");
          Console.WriteLine("How about some more.");

          Console.WriteLine("Is it greater?"+ (5 > -2) );
          Console.WriteLine("Is it greater or equal?"+ (5 >= -2) );
          Console.WriteLine("Is it less or equal?"+ (5 <= -2) );
     }
}

Exercise 2: Comments

Exercise 2: Comments

inspired by  http://learnpythonthehardway.org/book/ex2.html

using System;

public class Test
{
     public static void Main()
     {
          // A comment, this is so you can read your program later.
          // Anything after the // is ignored by C#.
          Console.WriteLine("I could have code like this."); // and the comment after is ignored

          // Console.WriteLine("This won't run.");
          Console.WriteLine("This will run.");
     }
}

Wednesday, January 13, 2016

Exercise 1: A Good First Program

Exercise 1: A Good First Program

inspired by  http://learnpythonthehardway.org/book/ex1.html

Type the following text :

using System;

public class Test
{
     public static void Main()
     {
          Console.WriteLine("Hello World!");
          Console.WriteLine("Hello Again");
          Console.WriteLine("I like typing this.");
          Console.WriteLine("This is fun.");
          Console.WriteLine("I'd much rather you 'not'.");
     }
}

Exercise 0: The Setup

Exercise 0: The Setup

This exercise has no code. It is simply the exercise you complete to get your computer to run C#/CSharp.

ideone.com (click to try)

Ideone is an online compiler and debugging tool which allows you to compile source code and execute it online in more than 60 programming languages.

Tuesday, January 12, 2016

Introduction: The Hard Way Is Easier

The Hard Way Is Easier

With the help of this book, you will do the incredibly simple things that all programmers do to learn a programming language:


  1. Go through each exercise.
  2. Type in each sample exactly.
  3. Make it run.

That's it. This will be very difficult at first, but stick with it. If you go through this book, and do each exercise for one or two hours a night, you will have a good foundation for moving onto another book about C#(CSharp) to continue your studies. This book won't turn you into a programmer overnight, but it will get you started on the path to learning how to code.

This book's job is to teach you the three most essential skills that a beginning programmer needs to know: reading and writing, attention to detail, and spotting differences.

Reading and Writing

If you have a problem typing, you will have a problem learning to code, and especially if you have a problem typing the fairly odd characters in source code. Without this simple skill you will be unable to learn even the most basic things about how software works.

Typing the code samples and getting them to run will help you learn the names of the symbols, get familiar with typing them, and get you reading the language.

Attention to Detail


Spotting Differences


Thursday, January 7, 2016

Preface

Welcome to the 2016 Edition of Learn C# the Hard Way.

=========================================

This simple book is meant to get you started in programming. The title says it's the hard way to learn to write code but it's actually not. It's only the "hard" way because it uses a technique called instruction. Instruction is where I tell you to do a sequence of controlled exercises designed to build a skill through repetition. This technique works very well with beginners who know nothing and need to acquire basic skills before they can understand more complex topics. It's used in everything from martial arts to music to even basic math and reading skills.

This book instructs you in C#(CSharp) by slowly building and establishing skills through techniques like practice and memorization, then applying them to increasingly difficult problems. By the end of the book you will have the tools needed to begin learning more complex programming topics. I like to tell people that my book gives you your "programming black belt." What this means is that you know the basics well enough to now start learning programming.

If you work hard, take your time, and build these skills, you will learn to code.

==========================================

Acknowledgements

I would like to thank Zed Shaw for helping me with this book.