C# for Intermediates: A Complete Course for Intermediate Programmers
By Lena Neill
()
About this ebook
You have learned the basics of C#, one of the most versatile and popular programming languages in the world. Now you are ready to take your skills to the next level and master the advanced features of C#.
"C# for Intermediates" is the perfect book for you. It covers a wide range of topics that will deepen your knowledge of C# and enhance your programming abilities. Some of the topics include:
The history and development of C#
How to use complex decision structures and control flow
How to work with various types of functions
How to manage memory and garbage collection
How to write asynchronous code and use its benefits
And much more…
This book is written in a clear and concise manner, suitable for intermediate learners of C#. It will help you to quickly and easily improve your C# skills and become a confident programmer.
Read more from Lena Neill
Programming for kids: The Comprehensive Course for young Coding Mastery Rating: 0 out of 5 stars0 ratingsPython Mastery: A Step-by-Step Course to Master Web Development, Data Analysis, and Machine Learning with Python Rating: 0 out of 5 stars0 ratingsJavascript: A Step-by-Step Guide for Beginners to Master Javascript Programming Rating: 0 out of 5 stars0 ratingsC# Mastery: A Comprehensive Guide to Advanced C# Features and Applications Rating: 0 out of 5 stars0 ratingsPython Machine Learning for Beginners: A Step by Step Approach to Scikit-Learn and TensorFlow Rating: 0 out of 5 stars0 ratingsC# for Beginners: A Step-by-Step Tutorial to Learning C# Programming from Scratch Rating: 0 out of 5 stars0 ratingsCybersecurity: Learn How to Prevent and Respond to Cyberattacks on Your PC, TV, and Other Rating: 0 out of 5 stars0 ratingsMastering Java: A Comprehensive Guide to Development Tools and Techniques Rating: 0 out of 5 stars0 ratingsC++ for Beginners: The Complete Guide to Learn C++ Programming with Ease and Confidence Rating: 0 out of 5 stars0 ratingsMastering C++: A Comprehensive Guide to Mastering Fundamentals and Crafting Data-Driven Debut Programs Rating: 0 out of 5 stars0 ratingsProgramming for Kids: A Step-by-Step Guide to Mastering Programming Rating: 0 out of 5 stars0 ratingsComputer Programming: A Comprehensive Beginner's Guide with a 4-in-1 Bundle Covering Python, SQL, Javascript and C# Rating: 0 out of 5 stars0 ratingsC++ Programming: A Complete Guide for Beginners to Master C++ and Build Robust Programs Rating: 0 out of 5 stars0 ratingsComputer Programming: A Simplified Entry to Python, Java, and C++ Programming for Beginners Rating: 0 out of 5 stars0 ratingsPython for Beginners: A Step-by-Step Guide to Master the Basics of Python with Easy Projects Rating: 0 out of 5 stars0 ratingsSQL Mastery: A Step-by-Step Guide to Learn SQL and Manage Data Effectively Rating: 0 out of 5 stars0 ratingsPython for Kids: A Beginner’s Guide to Learn Programming with Python Rating: 0 out of 5 stars0 ratingsProgramming for Kids and Beginners: 3-in-1 Masterclass into Python, Apps, and Games Rating: 0 out of 5 stars0 ratings
Related to C# for Intermediates
Related ebooks
C# Programming & Software Development: 6 In 1 Coding Syntax, Expressions, Interfaces, Generics And App Debugging Rating: 0 out of 5 stars0 ratingsC# Programming Illustrated Guide For Beginners & Intermediates: The Future Is Here! Learning By Doing Approach Rating: 0 out of 5 stars0 ratingsTake Your First Steps into Vue.JS Rating: 0 out of 5 stars0 ratingsJump Start Vue.js Rating: 4 out of 5 stars4/5Vue.js: 11 Practical Projects Rating: 0 out of 5 stars0 ratingsYour First Week With Node.js Rating: 0 out of 5 stars0 ratingsC# Programming Simplified: A Step-by-Step Guide for Beginners and Intermediates with Hands-On Projects Rating: 0 out of 5 stars0 ratingsBuilding Single Page Applications in .NET Core 3: Jumpstart Coding Using Blazor and C# Rating: 0 out of 5 stars0 ratingsC# Programming Fundamentals Rating: 0 out of 5 stars0 ratingsGetting to Know Vue.js: Learn to Build Single Page Applications in Vue from Scratch Rating: 0 out of 5 stars0 ratingsVue.js: Tools & Skills Rating: 0 out of 5 stars0 ratingsASP.NET and VB.NET in 30 Days: Acquire a Solid Foundation in the Fundamentals of Windows and Web Application Development Rating: 0 out of 5 stars0 ratingsVisual Studio Tips and Trips: II Rating: 0 out of 5 stars0 ratingsC# for Beginners: A Practical and Easy Guide to Master C# Programming from Scratch Rating: 0 out of 5 stars0 ratingsJavaScript: Optimizing Native JavaScript: Designing, Programming, and Debugging Native JavaScript Applications Rating: 0 out of 5 stars0 ratingsLearn Angular: 4 Angular Projects Rating: 0 out of 5 stars0 ratingsLearn ASP.NET MVC Rating: 4 out of 5 stars4/5Generic Pipelines Using Docker: The DevOps Guide to Building Reusable, Platform Agnostic CI/CD Frameworks Rating: 0 out of 5 stars0 ratingsNode.js: Novice to Ninja Rating: 0 out of 5 stars0 ratingsStart-to-Finish Visual C# 2015 Rating: 5 out of 5 stars5/5Vue.js for Jobseekers: A complete guide to learning Vue.js, building projects, and getting hired (English Edition) Rating: 0 out of 5 stars0 ratingsAdvanced Web Development with React: SSR and PWA with Next.js using React with advanced concepts Rating: 0 out of 5 stars0 ratingsJava/J2EE Design Patterns Interview Questions You'll Most Likely Be Asked: Job Interview Questions Series Rating: 0 out of 5 stars0 ratingsEnterprise Applications with C# and .NET: Develop robust, secure, and scalable applications using .NET and C# (English Edition) Rating: 0 out of 5 stars0 ratingsThe Easiest Way to Learn Design Patterns Rating: 0 out of 5 stars0 ratings
Programming For You
Python: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5Java for Beginners: A Crash Course to Learn Java Programming in 1 Week Rating: 5 out of 5 stars5/5SQL: For Beginners: Your Guide To Easily Learn SQL Programming in 7 Days Rating: 5 out of 5 stars5/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Python Machine Learning By Example Rating: 4 out of 5 stars4/5101 Amazing Nintendo NES Facts: Includes facts about the Famicom Rating: 4 out of 5 stars4/5Pokemon Go: Guide + 20 Tips and Tricks You Must Read Hints, Tricks, Tips, Secrets, Android, iOS Rating: 5 out of 5 stars5/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Learn SQL in 24 Hours Rating: 5 out of 5 stars5/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5PYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5Modern C++ for Absolute Beginners: A Friendly Introduction to C++ Programming Language and C++11 to C++20 Standards Rating: 0 out of 5 stars0 ratingsPython Projects for Beginners: A Ten-Week Bootcamp Approach to Python Programming Rating: 0 out of 5 stars0 ratings
Reviews for C# for Intermediates
0 ratings0 reviews
Book preview
C# for Intermediates - Lena Neill
Cha vpter 1: introduction - setup a vnd history of c#
Microsoft a vnnounced c# in 2000 a vnd la vunched the la vngua vge in 2002. c# wa vs supposed to be ca vlled cool,
which sta vnds for c-like object-orienta vted progra vmming.
c# is a v c-ba vsed progra vmming la vngua vge. it is pronounced c sha vrp
; the ha vsh symbol wa vs mea vnt to suggest tha vt c# is the la vter itera vtion of c++.
Below is the timeline of c#, deta viling wha vt ha vs been a vdded to ea vch version (c# introduction
):
Ja vn 2002
C# 1.0
Typesa vfe progra vmming la vngua vge
Modern
Oop (object oriented progra vmming)
Nov 2005
C# 2005
Generics
Pa vrtia vl cla vsses
A vnonymous types
Itera vtors
Nulla vble types
Sta vtic cla vsses
Nov 2007
C# 2007
Improvements of previous a vdditions
Extensions methods
Expression trees
Pa vrtia vl methods
A vpril 2010
C# 4.0.
Dyna vmic binding techniques
Unique na vming a vnd a vrguments (optiona vl)
A vug 2012
C# 5.0
A vsynchronous progra vmming (a v huge a vddition a vllowing progra vmmers to crea vte multithrea vded a vpplica vtions)
A vttributes for ca vller info
July 2015
C# 6.0 (this includes this book includes this version a vnd a vbove)
Exception filters
String interpola vtion
Na vmespa vces including sta vtic type members
Compiler a vs a v service
A vugust 2017
C# 7.0
Out va vria vbles
Tuples a vnd deconstruction
Pa vttern ma vtching
Loca vl functions
Expa vnded expression-bodied members
Ref loca vls a vnd returns
September 2019
C# 0.8
● rea vdonly members
● defa vult interfa vce methods
● pa vttern ma vtching enha vncements:
Switch expressions
Property pa vtterns
Tuple pa vtterns
Positiona vl pa vtterns
Using decla vra vtions
Sta vtic loca vl functions
Disposa vble ref structs
Nulla vble reference types
A vsynchronous strea vms
Indices a vnd ra vnges
Null-coa vlescing a vssignment
Unma vna vged constructed types
Sta vcka vlloc in nested expressions
Enha vncement of interpola vted verba vtim strings
Running c# on windows
You a vre proba vbly fa vmilia vr with a vll of the things we a vre going to cover in this cha vpter, but we ha vve to go through them beca vuse going through the ba vsics is a vlwa vys a v good idea v. think of it a vs a v much-needed refresher from those who ha vve stepped a vwa vy from progra vmming for a v bit. it's still a v better idea v to work with c# on windows, a vs c# is a v microsoft la vngua vge. the windows opera vting system is optimized for it.
Ma vc users:
You ca vn work with c# on ma vc. microsoft ha vs relea vsed a v visua vl studio version for ma vc, but the experience of working with c# on a v windows la vptop is better. it helps tha vt you ca vn run virtua vl windows os on ma vc using tools like virtua vl box by ora vcle.
1. object-oriented la vngua vge
Everything in c# is a vn object except for primitive da vta v types. objects, a vs you ma vy know, ha vve properties a vnd building functions. if you ha vve worked with other object-oriented la vngua vges, you ha vve seen this. we a vre going to see more of this in the upcoming cha vpters. c# is ea vsily ma vinta vina vble a vnd modula vr beca vuse it is object-oriented.
2. strongly typed
A vs you would expect from a v progra vmming la vngua vge ba vsed-off c, c# is strongly typed. mea vning, unlike ja vva vscript, you ha vve to specify da vta v types in your progra vm. this significa vntly reduces run-time error. this is referred to a vs type sa vfety. the benefit of type sa vfety becomes more a vppa vrent a vs you work with bigger a vpplica vtions.
3. a vutoma vtic ga vrba vge collection
C# regula vrly runs ga vrba vge collection, which removes unused objects a vnd da vngling pointers, refreshing memory. the .net fra vmework runs this ta vsk. you do not ha vve to do these cumbersome ta vsks yourself; it sa vves you time a vnd a vllows you to focus on your a vpplica vtions' functiona vlity.
4. ea vsy to lea vrn
C# is a v high-level progra vmming la vngua vge, which ma vkes it ea vsier to lea vrn. unlike low-level progra vmming la vngua vges like c a vnd c++, ma vny of the ta vsks you would ha vve to perform – like memory ma vna vgement a vnd pointers – a vre done a vutoma vtica vlly. this ma vkes your code a v lot more concise a vnd focused. something tha vt would ta vke ten lines of code in c ca vn ta vke a vbout three lines of code in c#.
5. a vpplica vtion ra vnge
C# is a vt the crux of microsoft's ecosystems. ma vny of its technologies run on it. windows phone used c#, a vsp.net used c# for its ba vckend, a vnd windows form a vnd windows presenta vtion fra vmework a vlso run on c#. if you a vre building something to run on windows a vnd wa vnt it to run well, c# is the best choice. there a vre other wa vys you ca vn write progra vms tha vt will run on windows, but performa vnce won't be the sa vme unless you go the extra v mile to optimize your progra vm. from web development, to a vpplica vtions, opera vting systems, a vnd ga vme engines, c# ca vn do plenty.
6. pa vrt of visua vl studio
Microsoft's visua vl studio is one of the most widely used ides globa vlly, a vnd c# is the pa vrt of visua vl studio la vngua vges tha vt highlights the importa vnce a vnd power of the la vngua vge.
7. huge developer community
When working with a v progra vm, it is a vlwa vys a v big help when the development community for it is la vrger. this mea vns tha vt if problems a vrise, it is more likely tha vt someone ha vs encountered tha vt problem, logged it, a vnd found a v solution for it. a vs a v result, you will not be stuck for long, a vnd you a vlwa vys ha vve free support a vva vila vble. c# ha vs the 4th la vrgest community on sta vck overflow. wha vt's a vlso interesting is tha vt sta vck overflow is written in c#.
Environment setup
Here is some of wha vt we ta vlked a vbout in the first book. when working with c#, it is best to do it on a v windows ma vchine with the la vtest .net fra vmework insta vlled. when you insta vll visua vl studio, a vll the files a vnd fra vmeworks you need to develop in c# will be loa vded to your system. visua vl studio is the go-to ide for c#. you ca vn downloa vd the la vtest visua vl studio here. you should see this when you do.
You will find visua vl studio in three versions: the community version, which is free, professiona vl, a vnd enterprise versions, which a vre pa vid. the community version requires you to ha vve a v microsoft a vccount. if you a vre on a v windows ma vchine, you proba vbly ha vve one a vlrea vdy. if you don't ha vve one, it is ea vsy to crea vte, a vnd it is free. the insta vlla vtion process is just like downloa vding a vny other progra vm. it does not do a vnything extra v.
Running your first progra vm
Follow these steps to run your first c# progra vm.
Open visua vl studio on the sta vrt menu or sea vrch for it in the windows sea vrch box (visua vl studio
):
Crea vte a v new project by selecting file -> new -> project a vs shown below.
You will be fa vced with ma vny c# progra vm options. select console a vpp (.net fra vmework)
a vnd give it the a vpplica vtion na vme you choose. i na vmed it myprogra vm.
click ok.
You will be na vviga vted to a v window where you ca vn write c# code. copy the following code in the window a vnd press the green button la vbeled sta vrt
from the top menu.
When you run the script, a vs you ha vve by pressing the 'sta vrt button, the console window will displa vy the result of running the script. in this ca vse, it displa vys the messa vge:
congra vtula vtions, you wrote your first progra vm". it looks like this:
To understa vnd wha vt ha vppened, let's ta vke a v look a vt the code tha vt we wrote:
Using system;
Using system.collections.generic;
Using system.linq;
Using system.text;
Using system.threa vding.ta vsks;
Na vmespa vce myprogra vm
{
cla vss progra vm
{
sta vtic void ma vin(string[] a vrgs)
{
console.writeline(congra vtula vtions, you wrote your first progra vm
);
console.rea vdkey();
}
}
}
Using sta vtements, the ones on top, a vre decla vred to import libra vries tha vt conta vin pre-built functions ca vlled methods tha vt we ma vy need in our code. a vny chunks of code in c# a vre pla vced within a v cla vss tha vt is inside a v na vmespa vce. this is to be expected, since the progra vm is object-orienta vted. in the progra vm we wrote, our cla vss is progra vm, a vnd our na vmespa vce is "myprogra vm ''.
Cla vsses, a vs a v type of object, conta vin methods within them. our progra vm cla vss ha vs the ma vin method whose return type is void, a vnd method type is sta vtic. the ma vin method is where the c# code we will execute begins. to write the line, we used the writeline method, which is pa vrt of the console cla vss. we pa vssed the text we wa vnt to see displa vyed in the console. then we used the rea vdkey method of the console cla vss to prevent the text from disa vppea vring once it is printed on the screen.
Tha vt is pretty much a vll there wa vs to our first progra vm.
Cha vpter 2: c# interfa vces
Interfa vces a vre cla vsses tha vt conta vin decla vra vtions of functions tha vt ca vn be inherited by other cla vsses. the cla vsses tha vt inherit the method define the method.
Interfa vces