Introduction to Programming
- Introduction to Programming
- What is C#?
- Your First Console Application in C#
- Introducing Methods and the Main() Function in C#
- Introducing C# Classes and Structs
- C# Data Types, Variables and Casting
- C# Program Flow Control and Entry Points
- Passing Parameters to Methods and Return Values in C#
- C# Access Modifiers and Scope
- C# Interfaces and Classes
- Using Namespaces in C#
- C# Conditional Statements
- Looping and Iteration in C#
- Using Arrays and Lists in C#
- C# Constants and Read-Only Variables
- Error and Exception Handling in C#
- Using Recursion in C#
- C# Operator List
- Class Inheritance in C#
- C# Class and Method Attributes Explained
- C# Class Constructors and Destructors
- C# Generics Variables
- XML Serialization and Deserialization
- C# String Formatting Examples
Programming is often thought of as a geeky and nerdy profession, but it is also obvious that creating software requires a certain amount of creativity. At the highest level, it must be clever but not complex, intuitive and easy to use. At the lower levels, creativity also plays an important role. Every line of code is like poetry, every instruction requires consideration of what came before it, and what comes after it. In this respect, programming is like writing a book or painting a masterpiece. Ultimately you have a finished product, but it's the sentences and the brush strokes combined, which is where the book, masterpiece or program truly comes to life.
What is a Program?
A program consists of a number of layers, the first being the User Interface. This is the part that you see on your screen, the buttons you click and the boxes you type into. Beneath that you have the Logical Layer, this is where the processing occurs. It takes uses the information you enter in the User Interface, does some number crunching and returns the results back to the user interface. More often than not, the logical layer will interact with the third layer - the Data Layer. This is where data is stored. The where and how does not concern us at this time, just be aware that it exists and is used to store and retrieve information.
What is a Program Made Of?
A program is made up of statements, often likened to sentences and called "a line of code". On its own it has structure and purpose, but without the context of the other statements around it, it isn't meaningful. Like a book, a program runs from the first statement, to the last, at which point it finishes and is closed. Unlike a book, the program can repeat itself, jump backwards and forwards through the chapters, return to the start or jump to the end.
Groups of statements are known as blocks of code and are often separated into distinct functions. A function is a block of code with a specific job to do that can be re-used anywhere else. When a function is used, we often say that it is "called". An example would be a program to calculate income tax for five people. Rather than writing the tax calculation code five times - one for each calculation - we can write the code once, turn it into a function, and call that function 5 times. This not only saves a lot of typing, but it also ensures that each of the five calculations are performed in exactly the same way. We can also call the function 10 times, 100 times or even 1,000,000 times without having to write it over and over again. This is called structured programming.
A programming language is the language used to code the program, much like the language used to write a book. Although the fundamental concepts and general practices remain the same, the overall grammar (programmers call grammar syntax) changes between languages. Some programming languages are very "human" orientated, and are written as it you were saying an instruction, while others are a bit more convoluted and require a bit of thought as to what they are doing. The BASIC programming language is one of the easiest to start learning as it is one of the most human orientated, although it is limited. C and C++ are some of the more powerful languages and they allow you to do a lot more than BASIC, however they are much more difficult to understand and to write.
Microsoft C# is a relatively new language and combines aspects of various languages to form an easy to use language, but also powerful. It combines the ease of use of BASIC and Pascal with the flexibility and power of C and C++.
I have written a series of tutorials for learning C# which should help you get started in programming using a modern, easy to use language.