Category: CSharp
-
C# 11 Inheritance
In the previous chapters, we looked at the basics of object-oriented programming in C#. Now that we have covered these basics, the next topic to be covered is that of class inheritance. What is inheritance? The concept of inheritance brings something of a real-world view to programming. It allows a class to be defined which…
-
C# 11 Tuple Type
Before proceeding, now is an excellent time to introduce the Swift tuple. A tuple is, quite simply, a way to temporarily group multiple values into a single entity. The items stored in a tuple can be of any type, and there is no requirement that those values all be of the same type. A tuple…
-
C# 11 Anonymous Methods and Lambdas
In this chapter, you will learn how to use anonymous methods and lambdas is C# to write flexible, concise, and reusable code. Topics covered in this chapter include creating and using anonymous methods, expressions, and statement lambdas. Anonymous methods Anonymous methods are also declared using the delegate keyword. Unlike traditional delegates, however, anonymous methods do not reference…
-
C# 11 Delegates
This chapter will continue exploring C# methods by introducing the concepts of C# delegates, including what they are and how to use them. What is a Delegate? Before we start exploring C# delegates it first helps to understand the concept of method signatures. When a method is declared, the parameters it accepts and the result…
-
C# 11 Methods
The previous chapter began the introduction to object-oriented programming in C# and included the use of methods declared within classes. This lesson will explore C# methods in more detail, including how they are declared and called, passing arguments, and returning results. The topic of passing arguments by reference and value will also be explained. C#…
-
An Introduction to C# 11 Object-Oriented Programming
Get up to speed in this chapter on object-oriented programming in C# with details on declaring classes, methods, fields, and properties. Topics covered include adding methods and properties to a class and creating, initializing, and finalizing class instances. So far in this course, we have looked at the basics of programming in C#, such as…
-
C# 11 Looping with do and while Statements
With the topic of constructing loops using the C# for statement, this chapter aims to introduce two more looping options: the while and do … while constructs. The C# for loop described in the previous lesson works well when you know in advance how many times a particular task needs to be repeated in a program. However,…
-
C# 11 Looping with the for Statement
This chapter will continue looking at flow control in C# code. In the preceding chapters, we have examined using logical expressions to decide what C# code should be executed. Another aspect of control flow entails the definition of loops. Loops are essentially sequences of C# statements that will be executed repeatedly until a specified condition…
-
The C# 11 switch Statement
In this chapter, learn how to use the C# switch statement as a cleaner alternative to complicated if.. else if… statements. In the previous chapter, we looked at controlling program execution flow using the if and else statements. While these statement constructs work well for testing a limited number of conditions, they quickly become unwieldy when dealing with larger…
-
C# 11 Conditional Control Flow
The cornerstone of any software code is the control flow logic which decides which code should be executed and which should not. In this chapter, we cover the conditional control flow constructs provided by C#. Looping vs. conditional control flow Regardless of the programming language used, application development is essentially an exercise in applying logic.…