Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

C# for Intermediates: A Complete Course for Intermediate Programmers
C# for Intermediates: A Complete Course for Intermediate Programmers
C# for Intermediates: A Complete Course for Intermediate Programmers
Ebook226 pages2 hours

C# for Intermediates: A Complete Course for Intermediate Programmers

Rating: 0 out of 5 stars

()

Read preview

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.

LanguageEnglish
Release dateFeb 26, 2024
ISBN9798224542314
C# for Intermediates: A Complete Course for Intermediate Programmers

Read more from Lena Neill

Related to C# for Intermediates

Related ebooks

Programming For You

View More

Related articles

Reviews for C# for Intermediates

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    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

    Enjoying the preview?
    Page 1 of 1