C# CRASH COURSE
Beginne r s Course To Learn The Basics Of C# Programming Language
Introduction
I want to thank you and congratulate you for downloading the book, C# Crash CourseBeginners Course To Learn the Basics of C# Programming Language
This book contains proven steps and strategies on how to master the basics of C# in just one week.
This eBook will teach you the fundamental ideas and concepts related to the C# programming language. It will explain programming lessons using clear words and practical examples. Actual C# codes and screenshots are also provided to help you understand the lessons. Additionally, this book will arm you with the skills, knowledge, and techniques necessary for becoming an excellent C# programmer.
After reading this material, youll become familiar with the C# language and the command console. Youll know how to send information to program users and how to obtain their inputs. Youll know to compile your programs and how to format your codes. Youll know how classes, variables, functions, methods, and data types work. Simply put, youll be a skilled C# programmer, and you can be so in as little as 7 days!
Thanks again for downloading this book, I hope you enjoy it!
Copyright 2015 by LIFE-STYLE - All rights reserved.
This document is geared towards providing exact and reliable information in regards to the topic and issue covered. The publication is sold with the idea that the publisher is not required to render accounting, officially permitted, or otherwise, qualified services. If advice is necessary, legal or professional, a practiced individual in the profession should be ordered.
- From a Declaration of Principles which was accepted and approved equally by a Committee of the American Bar Association and a Committee of Publishers and Associations.
In no way is it legal to reproduce, duplicate, or transmit any part of this document in either electronic means or in printed format. Recording of this publication is strictly prohibited and any storage of this document is not allowed unless with written permission from the publisher. All rights reserved.
The information provided herein is stated to be truthful and consistent, in that any liability, in terms of inattention or otherwise, by any usage or abuse of any policies, processes, or directions contained within is the solitary and utter responsibility of the recipient reader. Under no circumstances will any legal responsibility or blame be held against the publisher for any reparation, damages, or monetary loss due to the information herein, either directly or indirectly.
Respective authors own all copyrights not held by the publisher.
The information herein is offered for informational purposes solely, and is universal as so. The presentation of the information is without contract or any type of guarantee assurance.
The trademarks that are used are without any consent, and the publication of the trademark is without permission or backing by the trademark owner. All trademarks and brands within this book are for clarifying purposes only and are the owned by the owners themselves, not affiliated with this document.
Table of Contents
Introduction
Chapter 1: The Core Concepts of C#
Chapter 2: The Data Types, Variables, and Literals of C#
Chapter 3: The Operators of the C# Language
Chapter 4: Data Type Conversion
Chapter 5: The Console
Chapter 6: The Conditional Statements of C#
Chapter 7: The Loop Statements
Chapter 8: The Methods of the C# Language
Conclusion
Chapter 1: The Core Concepts of C#
According to computer experts, the best way to learn a programming language is by writing and analyzing codes. Thus, youll write an actual computer program before studying the language itself. This approach will help you to understand how C# works. Also, youll become familiar with the syntax and structures of this language.
Your First Program
Heres the code that you need to type:
This program prints Hello, C#! onto your computers default output device. Its still a raw program so you cant run it yet. For now, lets just analyze its structure. The next section will teach you how to compile and run programs using a command prompt and a programming environment.
How Does It Work?
This sample program consists of three parts:
- The class definition;
- The method definition; and
- The methods contents.
Lets discuss each part in detail:
The Class Definition The initial line of the program defines a class named HelloCSharp. The most basic class definition has two sections: (1) the word class and (2) the name of the new class. In this example, HelloCSharp serves as the classs name. Youll find the contents of this class inside the pair of braces (i.e. { }).
The Method Definition This part is located at the third line of the program. Here, you defined a method known as Main(). All C# programs use the main() method as their starting point. Heres the syntax that you need to use:
As you can see, Main() needs to be void and static. The arguments (i.e. the part inside the parentheses) are completely optional. That means you can simplify the Main() function into:
Important Note: Your program wont run if youll enter the Main() method incorrectly.
The Methods Contents Youll find the contents of any method after its name. In general, a pair of braces encloses those contents. The fifth line of the sample program uses an object (i.e. System.Console) and a method (i.e. WriteLine()) to display a message on your computers console. As mentioned earlier, the message is Hello, C#!
Important Note: When working on Main(), you may arrange C# expressions and statements according to your preferences. You wont get any error message even if you arrange those expressions and/or statements randomly. However, your completed program will run those entries according to their position inside the methods body.
The Rules You Need To Remember When Writing Codes
C# A Case-Sensitive Computer Language
This language is case-sensitive. That means you need to be careful with letter capitalization when typing C# codes. Basically, C# treats power, Power, and POWER as three different objects.
Important Note: You need to remember this rule. It applies to all of the elements of any C# program (e.g. variables, constants, classes, etc.).
Use the Proper Format
You need to add tabs, spaces, and newline characters to your code to improve its readability. These characters, which are ignored by the C# compiler, give an excellent structure to your source codes.
For instance, you may remove the newline characters from the HelloCSharp code:
As an alternative, you may remove the tab characters from it:
The last two examples work fine in terms of compilation and program execution. However, they are difficult to analyze, modify, understand, and maintain.
Next page