C# Programming Illustrated Guide For Beginners & Intermediates - William Sullivan - E-Book

C# Programming Illustrated Guide For Beginners & Intermediates E-Book

William Sullivan

0,0
3,63 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

C# Programming Illustrated Guide For Beginners & Intermediates


 Learn Coding Fast! With Practical Easy To Follow Examples And Step By Step Instructions!


Why should you choose to learn C# programming?


C sharp programing was developed by Microsoft and is USED in all their products!


 C# is definitely a great way to get started in the world of programming, and since one of the biggest software giants (Microsoft) developed this language it would make sense to learn from one of the most popular languages and most influential software developer in the history of the world!


This book offers illustrated step by step examples for you to learn from. No more boring 500+ page text books to read from, my book goes straight to the point and provides practical examples you can use for a more hands on approach.


Real Life Practical Uses of C#


 Windows Services


 Web Applications


Windows Applications


 Web Services


 Games


Console Applications


 Work-Flow Applications


Class Libraries


C# programming is becoming more and more popular with each passing day simply because it's an easy to learn language, robust, comprehensive, practical, and a general purpose language.


 C# programming is an in demand skill sought out by many employers and corporations worldwide!
So not only was it created by arguably one of the biggest software/tech giants in history, but it is also a skill that has a HUGE job prospect in today's modern world.


What You Will Learn


Object-Oriented Language & programming


Variables and Data Types


User Input and Console Output


Conditional Statements


Functions in C#


String Manipulation in C#


Polymorphism & Encapsulation


Practical Examples


 And, much, much more!


 Most books on programming languages can be expensive! - And Colleges charge you a fortune just for an introductory lessons.


My book is only a fraction of the price! Why not get started off at an affordable and reasonable price?


The greatest investment you can make is an investment in yourself. Invest in your knowledge base, and my book is your best starting point for both beginners and intermediates.


This is your in depth comprehensive guide with practical examples and illustrations to learn C# programming, whether you want to develop the skillet set for personal reasons or have a better chance at the job market using these highly desired and sought after skills, -this book is made just for you!


Its scientifically proven that illustration can help with your knowledge retention over 110%!


What are you waiting for? Make the greatest investment in yourself and grab a copy of this book.


Buy Now!

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Seitenzahl: 133

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



C# Programming Illustrated Guide For Beginners & Intermediates: The Future Is Here! Learning By Doing Approach

William Sullivan

Published by Healthy Pragmatic Solutions Inc, 2019.

Table of Contents

Chapter 1 - Introduction

Salient Features of C#

1. Object-Oriented Language

2. Strongly Types

3. Automatic Garbage Collection

4. Easy to Learn

5. Application Range

6. Part of Visual Studio

7. Huge Developer Community

Environment Setup

Running Your First Program

Conclusion

Chapter 2 – Variables and Data Types

Variable

Data Types

1. Numeric Types

2. Boolean Type

3. Char Type

4. String Type

5. Objects

Conclusion

Chapter 3 - C# Operators

1. Arithmetic Operators

2. Relational Operators

3. Logical Operators

4. Assignment Operators

Conclusion

Chapter 4 –Getting User Input and Console Output

Console Window

Printing Data on Console

Getting User Input

Conclusion

Chapter 5 – Conditional Statements in C#

If statement

If-else Statement

Switch Statements

Conclusion

Chapter 6 – Iteration Statements

The for loop

The while loop

The do-while loop

The break Statement

The continue Statement

Conclusion

Chapter 7 – Arrays in C#

Creating an Array

Accessing Array Elements

Traversing Arrays with the for Loop

Traversing Arrays with foreach loop

Multidimensional Arrays

Conclusion

Chapter 8 – Functions in C#

Declaring a Function

Calling a Function

Non-Static Function

Parameterized Methods

Returning Values from a Function

Passing Variable By Reference and By Value

Passing by Value

Passing by Reference

Conclusion

Chapter 9 – Object Oriented Programming in C#

Advantages of OOP

• Reusability

• Modular Approach

• Maintainability

• Easy Debugging

• Security

A Class

An Object

Accessing Members and Methods using Objects

The Constructor

Parameterized Constructor

Constructor Overloading

Conclusion

Chapter 10 – Inheritance in C#

Inheritance: A Simple Example

Multiple Inheritance

Calling Parent Class Constructor from Children Classes

Conclusion

Chapter 11 – Polymorphism and Encapsulation in C#

Polymorphism

Polymorphism via Method Overloading

Polymorphism via Method Overriding

Polymorphism by Overriding: An Example

Encapsulation in Python

Encapsulation via Customized Methods

Encapsulation via Properties

Conclusion

Chapter 12 – Exception Handling in C#

Compile Time Errors

Runtime Errors (Exceptions)

How Exceptions are handled

Conclusion

Chapter 13 – String Manipulation in C#

Creating a String

Using Single and Double Quotes

String Concatenation

Converting String to Lowercase and Uppercase

Finding Substring

Splitting Strings

Replacing a String

Finding String Length

Conclusion

Chapter 14 – File Handling in C#

Reading a File

ReadAllText()

ReadAllLines()

ReadLines()

Writing Data to File

WriteAllText()

WriteAllLines()

AppendAllText()

AppendAllLines()

Creating a File

Deleting a File

Conclusion

Chapter 15 – Collections in C#

What are Collections?

ArrayList

Creating an ArrayList

Adding Elements to an ArrayList

Removing Elements from an ArrayList

Accessing Elements from an ArrayList

Reversing and Sorting an ArrayList

SortedList

Creating a SortedList

Adding Elements to a SortedList

Accessing Elements in a SortedList

Removing Elements from SortedList

Stack

Creating a Stack

Adding Elements to a Stack

Accessing Elements from a Stack

Clearing the Stack

Queue

Creating a Queue

Adding Elements to a Queue

Accessing Elements from Queue

Clearing a Queue

Checking if Queue Contains an Element

Conclusion

© Healthy Pragmatic Solutions Inc. Copyright 2017 - All rights reserved.

The contents of this book may not be reproduced, duplicated or transmitted without direct written permission from the author.

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.

Legal Notice:

You cannot amend, distribute, sell, use, quote or paraphrase any part or the content within this book without the consent of the author.

Disclaimer Notice:

Please note the information contained within this document is for educational purposes only. No warranties of any kind are expressed or implied. Readers acknowledge that the author is not engaging in the rendering of legal, financial, medical or professional advice. Please consult a licensed professional before attempting any techniques outlined in this book.

By reading this document, the reader agrees that under no circumstances are is the author responsible for any losses, direct or indirect, which are incurred as a result of the use of information contained within this document, including, but not limited to, —errors, omissions, or inaccuracies.

Chapter 1 - Introduction

C# is the Microsoft’s premier language for software development. Microsoft developed C# between 1999 and 2002. In the year 2002, the first version of C# was released to the general public as an integral part of the .NET framework. Since then C# has taken over Visual Basic as the default language of choice for .NET programmers.

C# is one of the most powerful programming languages on the planet. Fully object-oriented and strongly typed, C# is currently being used for web development as backend language for ASP.NET web development framework. It is also widely being as backend language for Windows Forms and Windows Presentation Framework applications. In the world of mobile application development, C# is ruling the Windows Phone development arena.

Salient Features of C#

Following are some of the most important features that make C# so powerful and versatile:

1.  Object-Oriented Language

C# is 99.9% object oriented. Like Java, apart from the primitive data types, everything in C# is an object. An object has some properties and can perform some functions. We will see object-oriented programming in detail in a future chapter. For now, just remember that it is the object-oriented programming owing to which C# is modular and maintainable.

2.  Strongly Types

C# is a strongly typed language which means that you have to specify the type of data before the program compiles. This is also known as type-safety, which makes C# applications more robust and less prone to run-time errors.

3.  Automatic Garbage Collection

In C#, the garbage collection is performed automatically. After a certain amount of time, .NET framework runs garbage collector automatically which removes all the unused objects and dangling pointers from the memory.

4.  Easy to Learn

Unlike C or C++, which are considered mid-level programming languages, C# is very high level. Most of the functionalities that require careful handling in C or C++ such as pointers and memory management are handled by default in C#. You can literally set yourself up and write a C# program in less than 10 minutes.

5.  Application Range

Since C# is Microsoft’s premier programming language, almost every Microsoft technology depends upon it. For instance, ASP.NET framework runs C# as backend language, Windows Phone development also utilizes C# and, Windows Form and Windows Presentation Framework (WPF) also depend heavily on C#.

6.  Part of Visual Studio

Microsoft’s Visual Studio is one of the most widely used IDEs in the world and C# is the part of Visual Studio languages which highlights the importance and power of the language.

7.  Huge Developer Community

C# has a huge developer community. You can get help almost immediately about any problem that you might face during C# development. On www.stackoverflow.com, C# has the 4th largest community. Not to mention that www.stackoverflow.com was also developed using C#.

In short, C# has everything that it takes to become a professional programmer.  Enough of the theory, in the next section, we will install the environment that we are going to use to run our application.

Environment Setup

Ideally, to run the C# application, you should have a window machine with .NET framework installed. However, for the starters, I would recommender simply downloading the latest version of Visual Studio, which installs everything that you need to run your C# programs. Visual studio is the first choice IDE for C#.

The latest version of the visual studio can be downloaded here. Once you open the link, you should see the following interface:

Visual Studio comes in three versions: Community, Professional, and Enterprise. The Community version is free of cost while the Professional and Enterprise versions are not free. For the sake of this book, we will only use the Community version. To download the community version, you only need Microsoft account which you can create for free if you do not already have. Visual Studio installation is very straightforward and can be done with few clicks of the mouse.

Running Your First Program

Follow these steps to run your first C# program.

Open Visual Studio. You can do so by searching “Visual Studio” at the windows search box as shown below:

From the top menu, select File -> New -> Project. Look at the following screenshot for reference.

You will see a list of different types of programs that you can create with C#.  Select “Console App (.NET Framework)”, give any name to your application, I named it “MyProgram”. Click OK button.

You will see a window where you can write C# code. Write the following code in the window and press the green triangle with label “Start”, from the top menu. I will explain what is happening later.

Once you execute the script above, you will see that a console window, like the command line, will appear that will contain the message “Congratulations, you wrote your first Program” as shown below:

Now let’s see what is actually happening. Take a look at the code that we wrote:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace MyProgram

{

class Program

{

static void Main(string[] args)

{

Console.WriteLine("Congratulations, you wrote your first Program");

Console.ReadKey();

}

}

}

The using statements at the top of the code are used to import any libraries. Libraries are basically set of pre-built functions that we can directly use in our code. Every code snippet in C# has to be inside a class which in turn lies inside a namespace. In the script above our class name is Program and it lies inside the MyProgram namespace.

Inside the Program class, we have method Main whose return type is void and method type is static. This is the starting point of our code. Do not worry much about the terms void and static at the moment. We will see these terms in detail in a later chapter. For now, just remember that the Main method is the starting point of C# code.

Next, we write a simple line on the screen. To do so, we used WriteLine method of the Console  class and passed it the text that we wanted to display on the console window. Finally, we used the ReadKey method of the Console class so that our console window doesn’t disappear immediately after printing the text. And that’s pretty much it. Congratulations on successfully executing your first program.

Conclusion

C# is one of the most frequently used programming languages in the world. In this chapter, we studied some of the salient features of C# followed by the environment setup. To get our feet wet, we actually ran a very small program to see how C# program executes. In the next chapter, we will start our discussion about Data types in C#.

Chapter 2 – Variables and Data Types

Type safety is one of the most important features of C# language. In C#, the type of the data is specified at compile time which makes the application robust. In this chapter, we will see how C# handles a variety of data ranging from numbers to texts and dates to Boolean. However, before that, we will define what is a variable is.

Variable

A variable in C# is a code feature that is used to store data that is changed repeatedly. A variable in C# is similar to the variable in Mathematics to which a new value can be assigned, updated and deleted. Normally a variable is used to store data that is required throughout the application execution time. A type is associated with a variable. For instance, a variable that stores textual data in C#, cannot store numeric data. Similarly, if a variable stores a Boolean value i.e. true or false, you cannot store a numeric or text value to that variable. This is what makes C# strongly typed. A variable is declared in C# by simple prefixing the data type before the name of the variable. Throughout this book, we will make extensive use of the variables. But before that, we need to understand the different data types.

Data Types

C# data types have been divided into five categories. They are as follows:

1.  Numeric Types

These types are used to store integer numbers. They include int, unint, long, ulong, sbyte, byte, short, ushort.

The following table shows the value that these integer type variables can take along with their default values.

Data Type

Default

Min Value

Max Value

sbyte

0

-128

127

byte

0

0

255

short

0

-32768

32767

ushort

0

0

65535

int

0

-2147483648

2147483647

uint

0u

0

4294967295

long

0L

-9223372036854775808

9223372036854775807

ulong

0u

0

18446744073709551615

float

0.0f

±1.5×10-45

±3.4×1038

double

0.0d

±5.0×10-324

±1.7×10308

decimal

0.0m

±1.0×10-28

±7.9×1028

Let’s take a simple example of integer type data. Execute the following script:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace MyProgram

{

class Program

{

static void Main(string[] args)

{

Console.Write("Age:" + age + "-  balance:" + balance + "  - weight" + weight);

Console.ReadKey();

}

}

}

In the script above, we create three variables age, balance and weight. The first variable is integer type, the second variable is long type while the third variable is decimal type. We then print the three values on the console. The output looks like this:

2.  Boolean Type

The Boolean type variables can only have one of the two values: true and false. Let’s take a simple example of a Boolean variable:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace MyProgram

{

class Program

{

static void Main(string[] args)

{

Console.WriteLine(comparison);

Console.WriteLine(comparison);

Console.ReadKey();

}

}

}

In the script above we create a Boolean variable comparison. The variable can contain only true or false values. We then evaluated an expression where we say that 10 is greater than 20. Since, this is not true, false will be stored in the comparison variable and will be printed on the console. Next, we evaluate the expression 20 is greater than 10 which will return true this time and hence true will be printed on the console. The output of the script above look likes this:

3.  Char Type

The char type variable, as the name suggests is used to store the character values. The following example demonstrates this concept:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace MyProgram

{

class Program

{

static void Main(string[] args)

{

Console.Write(bloodgroup);

Console.Write(sign);

Console.ReadKey();

}

}

}

In the script above, we declare two character type variables sign and bloodgrpup. We assigned some values to these variables and then printed them on the screen.  It is important to mention here that a character can only hold a single value. For instance, you cannot assign a value ‘O+’ at once to one character. You will see an error if you do so. To handle a series of characters, the string type is used.

4.  String Type

String type variables can be used to store more than one character. Take a look at the following example:

using System;

using System.Collections.Generic;

using System.Linq;