C# Advanced Programming Techniques | Dániel Ernő Szabó | Skillshare

Playback Speed


1.0x


  • 0.5x
  • 0.75x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 1.75x
  • 2x

C# Advanced Programming Techniques

teacher avatar Dániel Ernő Szabó, Pythonista in the making

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

    • 1.

      C# Advanced Introduction

      0:47

    • 2.

      C# Advanced The Setup

      1:32

    • 3.

      C# Advanced Logical and Bitwise

      7:05

    • 4.

      C# Advanced Const vs Read Only

      6:18

    • 5.

      C# Advanced Scope and Visibility

      8:29

    • 6.

      C# Advanced Unsafe

      8:02

    • 7.

      C# Advanced Generic Collections

      10:21

    • 8.

      C# Advanced Explicit vs Implicit Conversions

      6:50

    • 9.

      C# Advanced Expression bodied functions

      7:50

    • 10.

      C# Advanced Operator precedence

      3:01

    • 11.

      C# Advanced Method entry and exit points

      4:14

    • 12.

      C# Advanced Generic parameter constraints

      8:04

    • 13.

      C# Advanced Open and Closed generic types

      7:48

    • 14.

      C# Advanced Out parameters and discard

      7:47

    • 15.

      C# Advanced Preprocessor directives

      8:29

    • 16.

      C# Advanced Overload indexers

      13:23

    • 17.

      C# Advanced Common predefined attributes

      14:05

    • 18.

      C# Advanced Read only autoproperties

      6:16

    • 19.

      C# Advanced Syntax for literals

      7:20

    • 20.

      C# Advanced Returning read only references from functions

      9:18

    • 21.

      C# Advanced Method without a name

      8:52

    • 22.

      C# Advanced LINQ

      8:54

    • 23.

      C# Advanced String interpolation

      7:19

    • 24.

      C# Advanced Value and reference type assignment

      10:41

    • 25.

      C# Advanced Null propagation operator

      6:14

    • 26.

      C# Advanced Clojures and lambda expressions

      7:57

    • 27.

      C# Advanced Foreach and enumerators

      6:52

    • 28.

      C# Advanced Static vs instance members

      7:40

    • 29.

      C# Advanced Type inference

      7:00

    • 30.

      C# Advanced Local functions

      9:02

    • 31.

      C# Advanced Custom event accessors

      9:16

    • 32.

      C# Advanced User defined conversions

      6:22

    • 33.

      C# Advanced The End

      1:05

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

58

Students

--

Projects

About This Class

Welcome,

This is the continuation of my previous C# class where more advanced programming techiniques are discussed and shown how to use the language.

The C# programming language was designed by Anders Hejlsberg from Microsoft in 2000 and was later approved as an international standard by Ecma (ECMA-334) in 2002 and
ISO/IEC (ISO/IEC 23270) in 2003. Microsoft introduced C# along with .NET Framework and Visual Studio, both of which were closed-source.
At the time, Microsoft had no open-source products. Four years later, in 2004, a free and open-source project called Mono began,
providing a cross-platform compiler and runtime environment for the C# programming language.
A decade later, Microsoft released Visual Studio Code (code editor), Roslyn (compiler), and the unified .NET platform (software framework),
all of which support C# and are free, open-source, and cross-platform. Mono also joined Microsoft but was not merged into .NET.

As of 2021, the most recent version of the language is C# 10.0, which was released in 2021 in .NET 6.0.

This course is going to build up the knowledge for you to create your own C# applications with ease.

Happy Coding!

Meet Your Teacher

Teacher Profile Image

Dániel Ernő Szabó

Pythonista in the making

Teacher

Hello, I'm Dániel Ernő.

I currently work as a devops engineer. I have several years of experience with various platforms and I'm here to teach some advanced techniques which may attribute your job security ;)

Cheers,

Daniel

See full profile

Level: Beginner

Class Ratings

Expectations Met?
    Exceeded!
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. C# Advanced Introduction: Hello there and welcome to my course and advanced C-sharp topics. In this video series, we are going to be upon the previous course or class details and continue our journey to take a look at advanced concepts in C-Sharp. And this course is going to be accompanied with a Git repository, which is going to allow you to further your knowledge, reproduce the examples. So if you want to learn something more complex and C-sharp, then this course is going to be right for you. See you in the next. 2. C# Advanced The Setup: Hello there and welcome back. In this short video, we are going to see the environment in which you can follow along the examples. So basically, you have two options. One is that you can use with rushed Visual Studio, you can use the 29th version or the 2022 version. You can download it from the official Microsoft side. And basically, what you have to do is to open the Visual Studio Installer. And you can click on modify. Here. You need to have the dotnet development checked and installed. Once you have this installed, you will be able to follow along. That's one option. The other option that you can use is the Visual Studio Code. And Visual Studio Code, you can check the extensions and check for C sharp. This is a little bit slow. But basically, if you install this extension, you should be also fine. So that was all I'm using, basically a Windows machine. And that's it. See you in the next one. 3. C# Advanced Logical and Bitwise: Hello there and welcome back. In this video, we are going to hold on. We're going to talk about logical and bitwise operators and how you can use them. So logical and wise. Alright, let's create it. So basically, when we talk about logical and bitwise operators and C-sharp, C-sharp supports four main types of operations which are grouped together based on the idea behind their existence. So categories are arithmetic, relational, logical, bitwise assignment, and some miscellaneous operations. Arithmetic operators usually perform operations on two numbers. So you want to sum two numbers, multiply, divide, and so on. The relational operators are used to compare or Chegg, quality of the input object or objects. And the logical operators allow us to compare a bit of a given object and always returns a Boolean as resorts. So whether it's true or false, bitwise operators perform operation on individual bits and the results are always bits. And assignment operators allow us to initialize an object with a value to perform a specific operation. And there is also another important concept which is the operator precedence, which operators are stronger than the others. And this tells the logic of how complex expressions are evaluated. So if we want to take a look at logical operators, we could do the following. Let's add the right key at the end. And we could say that we have a Boolean a, which is true, and the Boolean b which is false. We could use the console right line to check whether what's the value of a and B. Or we could check the value of ohms or right line a or B, and so on. If we start this or either execute it, we can see that a and B is false and a or B is true. So when we are talking about the end operator, we have to know that the condition is true when both of the inputs are true, otherwise it's false. The condition in case of OR operators, the condition is true when either one of them is true, otherwise it's false. So that's maybe about the logical operators and we have negation. And if you use exclamation mark before the variable, it will not get its value. So we have defined a s true, and here if we negate true, we get false. Now, what we can also check is the bitwise operators. So we can have an int array which is going to be six. And let's call them C and D. And the D is going to be 17. So if we want to use the bitwise operators, what we can do is the following. So we could use the convert to string. This is a function that allows you to convert a string. And we could say that a or B. And we could also use the two here. So let me just check it. So convert to string a or B. And if we go, Hold on, it's C or D. Alright? So basically when we use the OR operator, acts as if we had some that these two numbers. So we have the value of 23. And we could have, Let's check just to be twice representation of these numbers. So six is 0000110. And we have the 17, which is going to be zeros, zeros 010001. And we could also use the AND operation here. If we run it, we get this value. And you know, when we take a look at the end operation, we would get one. If in both cases there was a one, otherwise we get 0. That's why we get zeros. Result because none of these columns align up to get the value one. And we can use the bitwise AND operator. So that looks like this. And that's minus seven. And we could use the bitwise OR operator C or D. And this gives us 23. And technically that's it. That's what I wanted to show you in this video. See you. 4. C# Advanced Const vs Read Only: Hello there and welcome back. In this video we are going to talk about the difference between cost and read only. C-sharp. C-sharp facilitates keywords like concentrate only or static read-only even. And it can be confusing at first. We have to know the small differences between those. So the const keyword is nothing more but rather a constant. So for example, at cost string, my string. And we could say that this is a string. And let's change this to double-quotes. Alright? Now it's complaining that it is assigned, never used, but that's okay. So by default, if we don't give a value to this constant string, it will give us an error because it must be initialized. That's why it's underlined with red. But after we give it value, it should be just fine. And one, when we define the constant function, it is basically an exception to this. So for example, if you have a static string test, and we could say that we have a constant string test value and the return. So basically we have to write out the my constraint and the console right line. That's going to use phones all the three key. So we can have the prompt, let's execute it. The value of the constants cannot change during the execution. Recently, keyword is a special modifier which bears much resemblance to the constant keyword. And it can be used on fields, but not on local variables. So these fields can be either initialize when declared, what are the constructor of our object? And this keyword ensures that the variable instance or property of an object cannot be modified after initialization. And such attempt will result in an exemption exception. And why the constants in it is initialized at compile time. The read-only keyword allows the variables to be initialized either at compile time or runtime. So we could have the public read-only string column by Mike was to compile in it. And we could just leave it as it is. So for example, we could have like a class student. And this class could have the public read-only string, full name. And the public student string name. Full name equals name. And if you go to the main, we could create our student. Then ER and New Student, and use the console right line to print out the danielle for name. And now we can see the output. Is there. The core difference at the highest level if we want to differentiate the read only and the const keyword. So we could say that the difference lies in when the value of the variable is known through the lifecycle of application. For the read-only keyword, the value is known latest by runtime, which for the const keyword, the value must be known by compile time. The common of these keywords is that they both cover immutable data types, meaning the value cannot change throughout the life of the application. For the const keyword, the variable marked as such is placed by the compiler in the assembly metadata that defines the constant and the metadata and embeds the value to the intermediate language code after initialization. This means that there is no memory allocation than four constants during runtime under the hood, the read-only value is not a constant. It is stored in the loader heap, which is a memorial type that cannot be allocated until the type is loaded. So technically, that was all I wanted to tell you. See you in the next one. 5. C# Advanced Scope and Visibility: Hello there and welcome back. In this video we are going to talk about scope and visibility. So these are very crucial or basically crucial concepts to understand. And most of the programming languages out there incorporate this concept. The layout, the structure in which your data lives, and they show the direction the data is allowed to flow. First, we take a deeper dive into visibility to check the scope. So for example, if we talk about visibility, we need to consider a class method and variable visibility or atleast these constructs. Though, there are five different types of visibility. First one is public, the second is protected. The third is internal. Forces protected internal, and the fifth is private. Public is the most forgiving visibility type. The member defined this way can be reached from anywhere. The protected members specified can only be reached from the same class or from within the class. The internal members specified can be reached from the same project. And the protected internal members can be reached from the same project or those classes that inherit from the class, either from another project. The private members specified can be reached by other members of the same class. By default, classes structs are set to this visibility level. This is the most restrictive. So let's see demonstration. In the namespace, we will have the public class visibility. And we will have the public string message, which is I am visible from anywhere. And we will have the protected string beam message only from the same glass. And internal string message only from within the same project. And we will have the private string message, Dao chatbot. So we will have the public void. But architected message. This protected message is going to use the console. Right line, B message and console dot write line. But if the message, now, what we can have is another class. So public class B, which is going to inherit from the visibility class. And the public static. Void. Main is going to do this. So visibility, a new visibility. And a visibility B is going to be a visibility. Hold on. What we would like to do is to go ahead and use the phones or write line a message. Ones or one dot. Write line a message in the console dot write line aid at p0 message. And be Goodall, did Message. Then the cones are read. So now this can be deleted. We should have the right line and we will have the P message. We have the eye visibility, and we have the public static void, main. This is going to be the new AI visibility. We have the visibility V. And the I is the a visibility is new I visibility visibility to be as new visibility. And if we execute this, we should have the following output. So this demonstrates the visibility. When we are talking about scopes. This concept defines a part of the application where the variable is accessible and it is called the scope of a variable. Or variables can be defined in classes, methods, and loops. So for example, if we have a cast class level variable defined, it looks like this. So public class a. And we can have the event a, which is six. And when we declared a variable in the class outside any method, it can be accessed anywhere in the class. In our case, just like the variable a. When we define a variable this way they are called class fields or class members. So we can talk about method level visibility as well. And we can define, for example, void. First. This is going to be our method. And we will have a double C, which is going to be ten, that's 0. And we could have the console right line C. This way we demonstrate how methods encapsulate our own, their own namespace and the variables defined within. We can see how the variable's value is supposed to be printed out. And we can also create a block level variables. And those variables defined in a block are going to live only or be accessible while we are in the block execution. So that was all I wanted to show you about scope and visibility. See you in the next one. 6. C# Advanced Unsafe: Hello there and welcome back. In this video, we are going to talk about unsafe in C-Sharp. So basically we are talking about unsafe code in C Sharp. When we code the code, we run the code without supervision of the CLR, which is short for the common language run time. So unsafe code is a code which can include pointers. So you may draw a conclusion that the pointers are unsafe in C-sharp. However, it is not entirely true and we are here to shed some light into this mystery. So the CLR controls the execution of programs from loading to memory to exception handling type safety. There are numerous facilities provided by CLR and there are two facilities which are provided. The first is the garbage collector, which is supposed to clean up after unused objects. And the second one is thread management. So there are two main components of the.net framework. We have the base lab, BCL, which is the base class library, and the CLR, which is the common language run time. So BCL is nothing more than the standard dotnet library, which might be accessed through console apps, VPN apps, ASP.net, and so on. It's a set of predefined classes and functionalities that you can reuse. So basically I can be broken down into two more parts, the CTS, CTS and the CLS. The CTS is the common type specification and the CLS is the common language specification. We need to clarify two more concepts which are necessary to understand the answer code execution and what it means. So two types of code that is managed code and unmanaged code. The managed code is considered safe code. The unmanaged is unsafe code. So basically, managed code runs entirely under the supervision of CLR. It is tracked and garbage collected automatically. It also has access to the full arsenal of facilities provided by CLR. Now, here comes the pointers. So pointers are only interpreted in the context, context of unsaved or unsafe or unmanaged code. And a pointer can be a pointer type, a value type, reference type. So in order to define a pointer, we need the following code. We can have an int star, which is going to be called my int pointer. And we can have a void star, my void pointer. And the name of the type defined before the asterix is called the reference type. Pointer types do not inherit from the object place base class and there is no conversion between pointer types and the base object class. We can also define multiple pointers. So int, star by damage, my health, my experience, etc. The garbage collector does not protect the object's references. It means that even if pointer to a reference or a struct holding references, the garbage collector can collect it, or if it collect it. So if forbidden, it's, it's forbidden for a pointer to point to a reference or a struct that contains a reference. And we can have pointer of the base types in C sharps. So let's demonstrate it. I'm going to comment this out. So here we have array, which is going to hold two integers, which are going to be 12. And we can use the fixed int star p equals a 0. Here, what we would like to do is to have P2, which is equal to p. And use the console, the console, right, line, star V2 or asterix P2. So in order to get rid of the red down the line, we can say that this is unsafe. And basically after that, let's see the proof. Alright. Let's use the console. There are three key to read the value. So now as you can see, we have a pointer which points to the first element of the array, which is one. And the answer if keyword marks the section of the code that for the compiler that it will hold pointers. The fixed keyword means that we pin the asterix, be very able. So this one on top of our heap and the last asterix be plus equals one is called deference. They're referencing. So basically, if we go ahead and do something like this, so asterix p plus equals one. Then we can use the console dot write line asterix be. So now if you run it, you can see that we moved our pointer with one index. So there is a list of operators and statements which we can use to manipulate pointers in the answer if the context. So we can have basically the member access. We can have the indexing, we can have the address of a variable, we could have the arithmetic operators, and we can have comparision operators and so on. So we can have also some statements which is fixed and stack are log so stuck and locked means allocating memorial on the stack. And if you want to check the answer if coat properties, we can have methods, types, and code blocks, which can be defined as safe as the code is required for native functions which rely on pointers and Asif code, the introduces security and stability risks of code that holds our sub-blocks need to be compiled with unsafe that what we fixed here. And in some cases as if God can result in better performance since the array bounds checks are removed. So that was all I wanted to show you about unsafe. See you in the next one. 7. C# Advanced Generic Collections: Hello there and welcome back. In this video, we are going to talk about generic collections so we can call. So that's programming languages came to live. There was usually a common requirement amongst them and people wanted to store data in a structured way to later in time, they retrieve and manipulate it. That were generic operations which will commonly performed on these datasets like odd, remove, find, sort, replace copy, clone, number of elements stored, and so on. C-sharp and dotnet are no exception in this situation. So there are basically two types of collections which are provided with a framework to our disposal. First one is January, and the other one is non generic, but I had to dotnet version two, there are only collections. And if you want to categorize non generic collections, we can talk about ArrayList, hash table, sorted list, stack, queue, and the Generic Collections at least dictionary is sorted list stack and queue. So the main difference between genetic and non-genetic collections is that the value of types which they can store in the non generic collection. Each element can represent the value of different type. While the generic means that you can have only the same type. So basically, we need the system that collections are generic to use it. And it allows us to create, for example, a list of integers called my list. And basically we want a new list with, for example, ten values. This means that we have a list which can only store integers. It is called mylist and it ran half down values without the using statement, we could specify it the following way. So basically we could give the full path. That's just for interesting. For your interest. What we can also do is to check out the non generic hash table. A hash table. We should call it my hash. And this is going to have a new hash, the bar or rather hash set. Hash set and show potential fixes them. So system that call elections, that generic, that hash set. Alright, then we will have the HashSet. And this should be like an integer or something like that. And we to do with the n values, no. January in capacity. Or it should be HashSet D. But it should be C sharp hash, hash hash table. So Let's do this with the hash table. So let's accept it. Oh, this should be a system call actions that hash the bow, my hash. And now we can continue. So basically let's call this new system called elections. The ball. Great. So what we can do is the following, my hash. And we will have the skill share with the value first. And my hash that Ed Lu site. And this should be called second. Now, great. So what we can do here is the following. So for each 13 D in my hash. And I think this is also going to come from the system collections that dictionary entry. Great. What we can also do is to just simply outsource it here using system that collections. And now we can remove it. Great. So we would like to iterate over these and use the console right line. And we would have the D key equals that value. And use the console to read key. To accept this value, Let's run it. And if you run it, we should see the following output. So this is how we can use hash table. What we can also do is to have a generic ArrayList. So basically, let's create it array list. My list too equals new array list. And we would not give an argument in this case. And use the my list to add one mile is to add to my list three linear and so on. So just for demonstration sake, and for each object war for element in my list, two, we would go ahead and console dot write line element. Great. Now, what we can do is to see the output on the screen after execution. And basically that's it. So there is also another concept which is called boxing and unboxing. And this concept is very important when we're working with generics in C Sharp. In general, the concept and its realization provides some benefits of the strongly type collections as well as provide higher-quality and performance boosted code. There are two major categories for datatype is C-sharp. One is called value type and the other is called reference type. The boxing is the process of converting a value type to a reference type. And behind the scenes, the CLR allocates new object into the heap, then copies the value of value types value to that instance. For example, we have an integer which is a b with the value 99, an object B, which is equal to a. And let's change it this way. And we have a, C with the integer b. And now what we can do is to use the console right line, see, plus b, plus a. And there we go. So there is no space in between the space that it's not misleading. And here we go. So technically that was all I wanted to show. You. See you in the next one. 8. C# Advanced Explicit vs Implicit Conversions: Hello there and welcome back. In this video, we are going to continue our C-sharp journey. And we are going to talk about explicit and implicit type conversion. So basically, there are two main categories of programming languages. The first one is statically tab, and the second one is dynamically typed. So statically typed these like C-Sharp, C, C plus, plus and so on. And dynamically typed is like Python and Ruby and whatnot. And dynamic typing is sometimes also referred to as duck typing. So basically if it looks like a duck, walks like a duck and quacks like a duck. Then it's probably a duck. We're going to take a look at the features provided by C-sharp regarding static typing in C-Sharp, when a variable is declared, it cannot be declared again or assigned a value of another type. Type. Type is implicitly convertible to a given variable type. This is decided during compilation type and poses a restriction as to how a developer would use declare variables, although it also comes with a speed bump in execution. So statically typed languages are usually faster than dynamically typed ones, but both have their advantages and these advantages. So for example, if we say that we have an integer which is j in C-Sharp, then we cannot do the following. Assign string as a value. This is just simply not going to cut it. But what we can do is to assign a value of ten or do the following than 0. These are supposed to work. And this would give us an ad or because the integer and a string or not implicitly convertible, there might come a time when we need to copy a value of another value here, value of a variable to another variable, like passing integer to a method which takes a double long arguments or remain a to push variables between classes. So C-sharp provides ways of converting one type to another. One is implicit, the other is explicit. The third one is user-defined, and the fourth one is conversion with wrapper classes. So type conversion is also called casting or typecasting. Implicit conversions. What should we know about them? Basically, when we talk about implicit conversion, that is no special syntax for this type conversion. This is the safest type of casting. No data is lost. For example, converting from smaller to larger integer types or classes to base classes. That is an implicit numeric conversion table, which is, which comes in handy when we want to figure out which integers are compatible. And you can find it here on the Microsoft side. And for example, for an implicit conversion, we could use the following. Let's hide this. So we have an integer which is called number 128, and we would have a double, which is a bigger, and it's equal to the number. And the amplitude is an example of implicit conversion of class to base class would be something like that. Class a equals to new class. And we would have the base class C, which is equal to a. This is just an example because these are not well-defined, but this is how you could and should do it. And there are a number of conversions, sub-types which are all considered implicit. So for example, identity conversions, implicit numeric conversions, and so on. Now we have implicit conversion out of the way, we should talk about X plus calm versions. So this type of casting also involves a cost operator. And the process is usually associated with information loss or failure to convert between typically non-metric conversions. I mentioned when we convert from a larger precision datatype to a lower precision and sometimes converting from a base class to a database class is all show also mentioned here. So an example for an explicit conversion would be my pi. And we would say that we have an integer a and we would like to have the value as an integer of my pie associated with a. And if we were to use the console right line with a and my b, we would get the following Guanzhong greed key. Let's save it and run it. So we can see that the decimal, the numbers after the point where cutoff. In this case, we can talk about executed conversions between classes. So we have, for example, an OPA class, which is the car. And this would be an instance of the upper class. And we will have a car C, which is going to be equal to o. And we would have the OPA o equal to c. So this is an example for explicit conversion between class and base class. And basically that's it. What I wanted to show you. See you in the next one. 9. C# Advanced Expression bodied functions: Hello there and welcome back. Now what we would like to learn in c-sharp is the topic, the expression, but it functions syntax. But funk, synth Don't Save. Okay. So with the version of version six of C Sharp language, that feature was added to the programming language. It is called expression bodied members. The idea behind this feature was to make the code more readable and concise. And we are going to see in this video how this new feature can be incorporated into our code. So we have the members concept in C-Sharp, and it's related to object oriented programming. Numbers allow us to modify behavior of our class and change how it interacts with other classes and let it and capsulated information as needed. So members are the glue which keep the application together. So which are the members which are available? We have constructors, destructors, Property getters and setters, methods and indexers. The expression but in members can be applied to any of the above I mentioned, but we need to consider which one is available in our current version. So supported versions from the version six, the property getter and methods. From version seven, the constructor, destructor property sector, and the indexers. So let's take an example for the constructor and destructor. So basically we will have a class server. Inside our class, we will have the public string name and the public server string name equals name, equals name. And we need to make sure that this is the capital M and this is the capital N. Alright, now, we could have our destructor for the server. And we could just simply say on the console right line that the end is nigh. Alright. Now what we would have here, let's call this public class const buddy. And we would have our public static, void main. And we would have the server, which is a from the new server. Then here, or rather domain controller. And after that, what we could do is to use the console dot, write line a name, and use the console key. Wait for the prompt. Now if we execute it, we can see the following ODE. And yeah, basically that's it. So this is how we can use on members. What we can also do is to use it on basically accessors. So for example, if my server is supposed to have a public into V CPU, then we could have the get return the v Scott v CPU, and the sector return the underscore V CPU equals value. And yeah, we would have also the private int underscore V CPU. So this is how we could apply it to basically the access source. So we could go ahead and use a vCPU to be equal to ten. And we could add it to our output. If we execute it, we can see that this server, it has ten cores. And we could also have an indexer used. So technically if we define the public string and call this network, then this could be a new string with five values. And we could use the public string. And this int I get network adapters. And network adapters equals value. And there we have the network adapters with this string. And we should have this I. And this one with the index. This is how we would use it on indexers and we could also use it on methods. So basically if we define our public void, we could have the console right line booting up. And then say that the state is equal to Started. And for this to work, we need to define the pub private String state. And that's kind of it. So this is all I wanted to tell you about the expression, but it functions. So this is a newer and more concise way to use your classes with all their goodies. See you in the next one. 10. C# Advanced Operator precedence: Hello there and welcome back. In this video, we are going to talk about operator precedence in C-Sharp. So let's create new project for this. So basically, the order of terms and expression in any programming language is determined the outcome of the evaluation. And the operator precedence in C-Sharp determines how the grouping of these terms and expressions happen. And we will walk through the essentials as to what you must know this technique and create semantically correct apps. So there are three different types of operators that are unary, binary and ternary operators. And these define how many operands and operator can take. The United takes one, the binary takes two, and the tannery takes three operands. We need to talk about associativity. So basically, there are two types of associativity is, one is the left to right and right to left. And the operator precedence is meaningful only if there are higher and lower precedence operators in an expression. In this case, the precedence is from left to right. So for example, int x equals seven plus three divided by two. The order we need to remember is that when we talk about urinary, we have this following strength. So we have the size of the end, the star. The plus, the minus, the negation, the plus, plus and the minus minus prefixes. And then we have type cast. When we talk about conditional expressions, we have the question mark and the column. And we have simple compound assignments, Like equals times equals divided by equals, and so on. And we can basically change the precedence of the operators by parentheses is, and this is what I mean by that. In the first case, first we will divide three by two and then add seven. In the second case, we would add 37 and then divide by two. So that was all I wanted to show. You. See you in the next one. 11. C# Advanced Method entry and exit points: Welcome. In this video we are going to talk about methods, entry and exit points. So every C, C-Sharp application has an anthropologist called main method. This method is invoked first and whatever the business logic is implemented in your AP is controlled. From here. In this guide we're going to discover how CRM CLR, so common language runtime knows which method to call and when to call. And we're going to see the difference in these contexts between the executable applications and libraries. So CLR is the common language run time. It's purpose is to translate your code so that the hardware of your machine can understand your intentions. When you write the code in C-sharp, it is referred to as source code. The language specific compiler is going to turn that code into something called MSAL or Microsoft intermediate language. And sometimes it's also referred to as CIR, or common intermediate language. And basically, the intermediate state of the code also has language specific metadata and, and type implementation and the actual implementation of each of our classes, functions, methods, and so on. Now the CRM CLR steps in and provides a service and the runtime for your code to live in and the GIT, the adjusting time compiler also lives in this RAM, which turns the code into machine code, which in turn is executed by the CPU on your computer. The most basic example is what you can see on the screen. So Ponzo, that right line, hello world. And when we run this code, we can see that the Hello World is printed out on the console. And after that it closes. So when we have an app which is compared to an executable file, we have two distinct approaches for entry points. One is synchronous and the other is asynchronous. The type of main function is always static. And we have the option to choose if we are to return the status code after the application exists or not. And we need to use integer otherwise void. So synchronous methods are these. So if we go here and do this, so basic Curly, come on. We have a main which returns nothing without arguments. One is with arguments, and the other main is returning an integer without arguments and the other is with argument. And the other type would look like this. So we have something called task on domain. And it can also have argument and non argument versions. Why is it duplicate? The exit points serve as a control mechanism and they transfer back control to the caller. Either with the return value of a specific type or void. The main method reaching the exit points means our application is closed. So for example, if we were to say that we will return 0, then this is going to be our exit point, so to speak, in a function. And that is all I wanted to show you. See you in the next one. 12. C# Advanced Generic parameter constraints: Hello there and welcome back. In this video we are going to talk about generic parameter constraints. So generic became part of C-sharp with the version 2 of the language and the CLR, the common language run time. It has introduced a new concept of type parameters that allow you to design classes and methods that differ the specification of one or more tabs until the class or method is declared and instantiated by client code. So for example, if we were to create a class, class generic array d, and say that we have the public void. Summarize the input. And that's how you could define a generic class. And basically, these classes and methods combined three distinct features. One is reusability, the second is type safety, and the third one is efficiency. The generics are more often used in conjunction with collections and methods that operate on them. New namespace was introduced, which is called system that collections, that generic, that contains several new generic based collection classes. We also have the possibility to create custom generic types. So we need to talk about parameters as well. So we call parameter a placeholder for a specific type that the client specifies when they create an instance of a generic type. A generic class cannot be used as is, because it's simply a blueprint for that type and we need to declare, then instantiate a constructed type by specific type of volume. And we can have an example for that. So for example, if we have this generic array, which is an integer, then this is how we would instantiate it. And let's see the potential fixes. We don't one. Alright? So in this example we showed the instantiating instantiation for the blueprint of generic array with integer types. And in this case the parameter t is substituted at runtime. And with the type argument which allows us to create a type safe and efficient objects using one class definition. There are some rules on naming, so generic type parameters should have descriptive names and prefix descriptive type parameter T, or something like that. We also have eight constraints which we need to be aware of. So let me just copy and paste it here. So when d is a strikes, the argument must be a value type, except now the ball, when it's class, the argument must be a reference type and it applies to classes when t is not. Now the argument must be non, non-liberal. When it's unmanaged, the argument must be an M and each type, It's a base class. The argument must be dealt with from a base class. When d is a new instance, the argument must have a parent meter less constructor. When it's an interface them argument must be already implemented in a specific interface. And when it's you, the argument must be or daddy with from the argument supplied for you. So why do we use constraints? Enforcing constraints or specific type parameters allow us to increase the number of allowable operations and method calls to those supported. And what we would like to do is to create a demonstration for the exam. Let me just comment this out. Let's say we have a class, generic class with t, where t is a class. And we can say that we have a private read-only t, which is a field. And we have a public generic class, the field or rather value. And this underscores field is equal to value. We also have the public t generic method with the T bottom meter. And we can go ahead and use the console right line. And say that the type of the bottom meter is both T and value is value. Or rather bottom meter or meter. Alright? And the generic method. And women need to make sure that we return this field. And we can use the console right line. The printout that the return type of parameter is dipole. T value. This score field. All right, here we can instantiate our class. So we can have a generic class string a, which is equal to new generic class string hello world. And we can use the a dot generic method call. And we can use the console dot write line, not right line, read key to pause for a second. And let's give this the argument string. Alright, let's execute it. And as you can see, we have a string with the value string. And there we go. So these are the messages that we can see. Technically, that was all I wanted to show you. See you in the next one. 13. C# Advanced Open and Closed generic types: Welcome. In this video we are going to talk about the open and close generic types. So with the version two of C Sharp, a new concept has included, are introduced, which is called genetics. The basic idea was to allow specific type like float, double, or string to be passed as a parameter to methods, classes, and even interfaces. That is a very crucial limitation to collections, which is a lack or even absence of type checking. However, this allows you to add the objects of any type interconnection because they are all descendant of the object base class. This contradicts the basic definition of C, C-sharp as being a type-safe and comprises on type safety. In this guide, we will take a look at deeper as to what generics are and what they're open and close property means. The types in C Sharp have two main categories. One is called value and the other is called reference types. Both of them may be generic types that take one-on-one type parameters. So the closed January. So one of the most powerful features and C-sharp, which have developers defined types of data structures like collections. And this is, this is not just results in better code quality, but behind the scenes, it, it adds a decent performance boost as well. So let's check out how this looks. We will have a public class device. And this device is going to have a public d0 name, Get and Set. And the public T category. With the gatt and the set. We will have the public hold on. This goes here. So this is going to be the public class generics. And what we would like to do is to have the public static, void main. And inside the main, we would have the device with the string a as a new device Domain Controller. And let's just skip the name. Alright, yeah, Should we do this? And we have the device float b with the new device float. And let's just close it. And we can modify the a, that name to be the domain controller. And the a category to be this thing. And this goes for the B as well. Dns server will be in that category. And let's call it production. And what we can do is for example, hold on. This should be 1 f and 2 f. So console, right, line, a, name and a category. And the same goes for the B, O, K and use the colon. So read key to keep the console. Why we take a look at it? There we go. We have created a generic class which represents a device. And based on the type of the generic, we can initialize the values. And what we can also do is to create an open January. So we would like this code to demonstrate it. So we will have a public class, o g with the T. And we need to be using the system thought reflection. And here we will have the public in M, g. And we will have a woo hoo equal to 0. In order to use it, what we have to do is to create an instance. So we will have a public static void. Hold on. This is in the plant genetics are public. Static object. Will it run? And this is going to have the type of g enum type in for that. Get the cooler red field. Woo hoo. And we would like to get the value. And now what we can do is to go ahead and create a new instance object who will run. And we will have the console right line. Tell us the following. Is this generic? And we use the foo that type type info and is generic type definition. Now, this is how you can define the open generics. And by using reflection to get a constant field, the Woo-hoo. The CLR, automatically convert the integer into an instance of the open type. So basically that was it. What I wanted to show you in this video. See you in the axon. 14. C# Advanced Out parameters and discard: Hello there and welcome back. In this video, we are going to take a look at two features included in C sharp seven version. And these features essentially changed how developers worked and the applications were developed. The app parameter comes in handy when methods need to return more than one values. And this parameter is passed by reference and basically transform the formal parameter, an alias for the argument which must be a very able, very similar to the reference keyword. But the main difference is the latter needs to be initialized before hand. The discards basically temporary variable, so dummy variables that are used in application code. This cat's main purpose is to provide reusable variable which decreases the memory allocation and improves readability and maintainability. First, we are going to take a look at the OUT parameter. So basically it has three rules. Parameter can be passed without declaration and initialization. It can use var type in method parameter list. We don't have to have the same name for our parameter in the function and the core. So let's take a demo for that. We have a public static string, SLA. With the double a and double B. Inside this function, we would like to have a result which is coming from the math around a times b. Or rather, how should we do that? B divided by a. And we would like to multiply it by 100 and we need two digits. So this is what we would like to have. And we will have the string SLA equal to total hours available. Hours. And the SLA is the result. Now, what we would like to do is to return SLA. And what we would like to do after this is to basically modify our function signature. And we would say that our out double result and out string SLA are going to be other parameters. And we have to remove the initialization from that. We can use this function called from now on. So console right line. And we would like to use what would we use SLA. And basically, we would like to have then total hours available hours with eight. And we would like to have the novel result and out. String SLA and use the phones are key. To save it. Alright, let's start it. And as you can see, this is the result. What we can also do is to use this card. This card variables have the underscore symbol. So for example, if we create a variable which is called Coupa with 12345, then go ahead and do the underscore. Underscore, underscore equals coupon. Then what we can do is to use the console right line, the write out the first and the second. So let me show you. So this is basically the simple, this is a simple example for the discard and how to use it. And our task was to create two variables from which were named variables from the coupon and discard the rest of the values. And if we can say something like this, so the real power of this card is when we combine it with the outer variable. So for example, if we have public void, sorry, static, void B, S with the string d t. Then if the time that dry bars the SDR and out underscore, then we could say that the cones on that right line date is valid. Otherwise, console right line date is in Guanzhong. Left. Alright. Let's not forget this one here. And if we can go ahead and call the P S with the O2, 292022. We should see the following on our screen. And here we go. So technically, this is all I wanted to show you in this video. See you in the next. 15. C# Advanced Preprocessor directives: Hello there and welcome back. In this video, we are going to talk about preprocessor directives in C-Sharp. So basically, this concept belongs to the realm of compiled languages. Are compiled languages or language which takes some higher-level code like C-Sharp or C. And with the help of compiler, it translates it to machine code. The compiler is an abstraction layer between different architecture of manufacturers. It knows how to translate blocks of code to different architectures. So like, yeah, Intel or AMD processors. And the processor itself does not guarantee the final machine code. As its name suggests, it's only pre-processing the instructions. We have a higher level language. Then we have a pre-processor than a pure high level language, than a compiler and assembler, loader and the linker. So preprocessor directives can be the if statement as a leaf and if and so on. And we are going to take a look at a simple example. For example, if we want to use this directive, we could say that if debug, then we would like to say that system console, right line debug mode. We would like to say system console dot, write line, and know the bug. And then bring it here. And we can close this with the endif statement. And here we have defined a pre-processor directive which says that this should be only considered in debug mode. Otherwise, we print out no debug. And we can either run this solution in release or debug mode. And by default the debug mode is R1, and this is the output that we should see. So let's go ahead and use the system calls or read key. If we execute the solution, you can see that we are running in debug mode. And yeah, that was the demo. So we have defined an undefined. And these directives can be used to define or undefined directives for the preprocessor. And the most common use case for this is when we would like to define extra conditions for the compilation itself. So this usually is done in tandem with def directive. And basically we could go ahead and define the dev. And if fraud, we would like to say we defined debug and undefined, brace and end if. And we should put it in the first one. This is working. So what we can also do is to use the warning or the ad or and basically, we could say that if not corrode, not test and not Deb, then we can throw an error message stating that cannot combine. We omit a warning message stating that running with hard-coded. And we can end this if statement. And if we run this solution, we don't see anything. But the minute I remove this one, we see that there are adults in the build and we can see the error message that we cannot compile. So this is a behavior that we can implement. What we can do is to also use the align directive. So line that active allows us to modify the compiler slide numbering and even the filename for the adults and warnings. So let's say we would like to modify the file name reported when a warning is generated. So let's put it here and say that line, one, wanting line that C S. Now if we remove this, we should be able to execute our solution. We have this output. All right? Now what we would like to do is to learn about region and n region. So these directives are useful when we are working with Visual Studio Code editor or with the studio itself. And there is no special output from this diet active, but it allows you to mark specific regions which will be expandable and collapse, collapse CBO by your editor of choice. So for example, we could say that a region using and we could say that this is the end region. And now we are able to collapse it. And we also have the pragma, the pragma warning and pragma checksum. In simple words, pragma directive can be used to affect how the compile time reporting or warnings is handled and give special instructions to the compilers. So there are two basic variant. One is wanting, the other is checksum. When we use wanting, we have the option to specify either disabled or restore, followed by a list of warnings that need to be acted upon or nothing assumes every type of wanting the checksum congenital, it generates a checksum of the source file which will have the debugging. So for example, if we have the following pragma defined and run it, you will see that there are no issues found. Basically, that was all I wanted to show you about preprocessor directives. See you in the next one. 16. C# Advanced Overload indexers: Welcome. In this video, we're going to talk about overload indexers in C-Sharp. So in C-Sharp, we have many different data structures available. And these allow us to store and retrieve specific data at our time of need. In this video, we are going to learn about indexers and especially how you can overload them by doing the right way. When we talk about indexer overloading the idea behind this, the force, the class to behave like a data structure and keep track of its instances that allow us to retrieve those instances as we would do with an array, array of list. First, we clear the topic of in the indexers and then turn our sights to add overloading. So let's create a new project in the load. So that is a general, basically template syntax for this. And we are going to take a look at it in a practical example. So for example, let's say we have a class students. And here we have a private string array. And we will call this indexers, which is a new string with Dan values. And we have a public String. And it points to the index. And what we would like to do is the following. We will have the gatt, which will return the indexers index and the set, which is going to set the index to a specific value. Here in the main, what we would like to do is to create a new instance of the students, and let's call this elementary school. And here we would like to have the elementary schools first element with my name, and the elementary schools second element with my brother's name. And the elementary school second element get my sister's name. And what we would like to do is to take a for loop and iterate from 0 to I less than and print out the console right line. And the elementary school. I'th element. Then use the console read key to keep the prompt. Now, as you can see on the console, we have the three names. And of course there is blinking here because the rest of the list is empty. Now, what happens here? We have a class course, students behaving like a weird array and allowing up to ten students names to be stored in domain. The class is instantiated and three students are inserted. And if we were to set the following elements, so elementary school, TAM, a mother, then we should get an exception. Because there is no tenth element. The size just doesn't allow us that are important points here. So there are two basic types of indexes. One and two-dimensional. Index search can be overloaded and they are not equal to properties and it allows an object to be indexed and set accessor. We'll assign. Yet we'll retrieve a value. The value is used when you set the value. And indexers are referred to as smart arrays or parametrized properties, which can be a little bit misleading. And indexers cannot be static members as they are as members of the class. So how do we overload the indexers? Let's create a new class. Let's call these guides. And we have a private string, array and guide names, which is a new string. Dan values. We will have the public string, this int index is going to return the guide names index value. And the set is going to set the guide names index value to the specified value. And we could have the public during this with the float index. And we should have the same Get and Set functions. And we will have the public string, this double id. Let's modify this one. And we would have it set to one. And here we would not have a set definition. Both return something which is called, this is read only. And now in our main, if we comment this out, we can instantiate the guides. And we will have a double value, the k, and it's **** 0. And here the guides first element would be written. And the guides float index-based element would be on guides. And what we can do is to use the console right line. And we would like to print out the guides k element. And we would like to print out the first element. And we would like to print out the first plus the float based first element. Alright? So what we can see here is that we accessed basically different versions of this based on the type of indexer that we have used. And here we have an index which is an integer. And here we have one which is a float value. And we can reference these and manipulate based on that return value. And we have a final example that we would like to take a look at, and it would be called multidimensional more tea that I mentioned now. And here we will have the private string. And we have this comma. And we have the guide names, which is equal to new string ten times. Then we would have the public string, this int x and int y. And we would have the get, which returns the guide names x and y. And we will have the set which is going to set the guide names x and y to the value. And if we go ahead and instantiate it, so use them all. The diamonds are now a equals to new multi dimensional. And then use the a first. There'll be the Danio and a one to be another. Then we can use nested loops to iterate over j equals 0, j less than term j plus plus. And use the console right line. And we would like to use the a and y or j. And what we would like to do is to add the check. So if a x and y is equal to null, then we use the phones all that bright line with the f string. X and y is empty. So let's make this x, and let's make this y. And otherwise, sorry, I and j. And j. Otherwise, we would like to use this print out. Alright. So now on the output, this is what we can see. Why technically this is it. This is how you can overload the indexers in C-Sharp. See you in the next one. 17. C# Advanced Common predefined attributes: Hello there and welcome back. In this video we are going to take a look at the purpose of common predefined attributes in C-Sharp. So attributes allow developers to associate metadata or declarative information in their project and their code. One of the ways I prefer to use is tomorrow classes or functions obsolete as the app development continues? And first we are going to take a look at what attributes are and see some examples of that. So attributes are places in your code where we can define them. And they are like assemblies, methods, types, and the list goes on. Once you have associated the attribute with our selected part of code, we have the option to query it with a technique called reflection. In the.net framework, every type and components like assemblies and classes have their own metadata defined by default, which can be extended by custom metadata information as we, we are on the goal. And when we apply metadata information, we have the option to choose the scope. We can apply it to entire assemblies or just specific parts of our code. Attributes have the special ability to further, to be furthered configured with parameters. And finally, the most special thing about metadata is that our application can inspect its own metadata and inspect other progress metadata as well. This allows us to build in compatibility checking and other nice features. So there is this skeleton code which we can use. And this is going to be telling us that this is a positional parameter, it has value and so on. Let's say we have the following code which represent the sweater machine and it has two functions. One is our starting the machine and the other is installing updates. So we have the public class server, and it has the private string name. And it has the public string name, property name. And set name equals value. Sorry, underscore name. And we have the public string name, constructor name. It comes to specify a name. And we have the public void update server, which is going through right to the console. That updating server. And we have the start. And it's going to say that we are restarting the service. Great. So now what we would like to do is to close out our class. Yeah. And as the project evolves, we would like to add the next function which is going to deprecate the update server and handle both the update and the installation and the rest start task with some extra step. So how do we let, let the developers know that the new function will be introduced, which covers these. All it is. What we can do is to add the new line or rather function definition. And then say to the update server that this is obsolete. And what we would like to do is to tell the dune to use this method, use the start instead. And we can have also this false falls here. So now we have this, this way. Alright? So the key point here is this line, and it needs to be accurate with the function names. Otherwise, the compiler will throw an error stating that the method we are referring to cannot be found. So what we would like to do is to copy this one and Sure that this is also correct. And it needs to be accurate for the function names. Otherwise, the compiler will throw an ad or stating that the method we are referring to cannot be found. The second argument is either true or false. When we set it to false, the compiler will throw a warning, but the compilation we'll go through. If it is set to true, an exception is raised and the compilation stops. And that is also a concept which is called attribute targeting. And it points to the entity where the attribute is targeted to. In this case, the a function is the target. Now we can talk about predefined attributes. These attributes referred to a set of attributes which are built into the document library by Microsoft. And we need to be aware that that is a base class for attributes, which is called system that attribute. And every customer predefined attribute inherits from this base class. Most common predefined attributes are serialization, serialization, obsolete, DLL, important, and wet method. What we can do is to define our customer attributes. So anyone using the.net framework and define their cost of absolutes, it can be for private or private use, are packaged into public library or application. What we would like to do is to go ahead and create the following demonstration. So we have to import the system that reflection. And what we want to do is to define a class. And the attribute usage of this class will be the attribute targets that class. And the class is going to be called company attribute, which will inherit from the attribute base class. And we will have the private string name, private string location. And the public string name with the gap. That returns the name. And the set, which is going to set the name equal to value. And we will have the public string location. And we would have a constructor. So public company attribute and the string company and the string location. And we would like to have the name equal to company and the location equal to location. Alright? So now that we have this out of the way, we can have new attribute base class where the company is going to be imaginary. And it will have something located in Atlanta. This, this is going to be called class server. And it will have a private string name. And the private string. This public string name. With the GET. Come on. That returns the name and the set which returns name equals value. Alright, so we have this public class. Let's call this company server, sorry. And we will have these functions repurposed. So we have these obsolete function and we have the rest start and add it in dressage functions. And here in the main, we can create a server a from the new company server domain controller. And why is it crying? It has no constructor, of course, because it needs to be defined. So public, company server, string, name, and the name is equal to the name. Alright, now we have the constructor and we will have the member info. Info equals type or a nut type of fame, but rather the company server. And the object array with the attribute is going to be the info, get custom attributes. Die both company attribute and a false. Alright? And after that, we can use the foreach loop to iterate over each object attribute in attributes. Then just simply use the company attribute C equals to company attribute, attribute. You. And cones on the right line. Dollar sign, quote, a, name and a location or not. B. C, That locations, sorry. And we can use the ones on the three key to keep the prompt. Alright, now as you can see, we were able to get the attribute from a specific instance. And this is how you can use common predefined attributes in C-Sharp. See you next time. 18. C# Advanced Read only autoproperties: Welcome. In this video we are going to talk about three, the only auto properties in C-Sharp. So read only auto properties. What are they? We diverge and six have C-sharp released in 2015. So like seven years didn't go alongside the visa Studio Ultimate. That was a very unique feature implemented. This is called read-only auto property and sometimes referred to as getter only auto property. So in this video, we are going to take, take the concept of fields and properties and see how both can be read-only and how they are implemented by focusing on the auto property aspect. So fears versus properties. These two concepts revolve around the idea of abstraction. With the class. You can have fields and properties. Fields are normal variable members or of class. Why did I write car? A car class? And properties are an abstraction which allows you to get or even set their values. So for example, we could create the public field class and we would have sorry, class, okay. Private string name and private string function. And what we can do is to define these so-called fields in a construction constructor. So public server healed, we would have the string name, string function. Here. What we would like to do is to say that this name is equal to name. And this function is equal to function. When we define fields, we should make sure that we define them as private. As this ensures we're not violating the concept of encapsulation. Encapsulation in short means that we are building the fields, but we are bundling the fields or data with methods and functions that are capable of manipulating them. And we do not expose this data for direct manipulation. And this current code is not really sufficient because we are not able to retrieve these. So what we have to do is to go ahead and define the following public string name, name. And we would use to get to return the name and the set, the set, the name to the value. We would have the public string function, and we would get the function and set the function to value. And we now have, we now have the option to read and modify the properties. So let's see our cold. So server field a equals new sandwich field. And the name is DC. The function on the silver thread rather is one. And the function is domain controller. Alright? Now what we can do is to use the console right line, the printout, a name and a function. And don't forget the console that three key. So when we run this example, this is what the output is. So we have successfully set and accessed these, and we have initialized our class with a constructor later the fields were changed with the help of property accessors. And we have obeyed the encapsulation principle as well. Now that we clarify the concept, we can spice it with the read-only aspect. When we want to create a read-only field, we only have to use the Read Only keyword. So if we modify this to read only, then we can see that the name underscore is going to be red. And in this case of a fear number, this means we only get one chance to initialize the field with value. It happens when we call the constructor constructor and be on that we would get an ad or from such attempt. So this can be safely removed. If we were to execute this once again, you can see that it is working fine. But if I attempt to say that the name equals new name, what I should see is that this is a read-only property and cannot be modified. Alright? So in case of field number, alright? And we have seen the output. So this is how you can use read-only Alto properties in C-Sharp. See you in. 19. C# Advanced Syntax for literals: Welcome. In this video we are going to talk about how you can recognize syntax for literacy, including Unicode deck skip sequences and underscores in C-Sharp. So let's jump right to it. Later us in C-Sharp and nothing more than fixed values. These values are used by variables or constants. There are many types of literals, like integer, floating point, character, string, boolean. And if we take a look at integer literals, this would be an example. And it's a type of literature which concerns integers. And there are basically three subtypes, decimal, octal and hexadecimal. This is the decimal. What we could do is to create the octo, which is the, oh, come on. And eight. And now 028. And we can have the hex, which is 0 x one, C for example. And basically what we could do is to go ahead and use the cones or left to right line. And say that the variable name of a has value. And do this for all three of them. So this is for the O and the H. And don't forget the colon, so read key. So if we run it, this is what we have on the screen. So note how the name of allows us to refer to the name of a variable in our string interpolation. The other thing we may not notice is how the values show in case of hexa and octal number. And they basically like the preface prefixes. We don't see the hex prefix or the prefix. What we can do is to create a floating-point literals. So let's create the float f k equals 283848. And we could have the floating, floating octo F B, which would be the 28 or 27 minus five. And we could The, sorry, d and novel. Yeah, now it seems to be better. So we could have the 28th F. And now what we can do is to print out the values. So the a, the B, and the C. And if we run it, note how this also has the different notation when it is printed out to the screen. This is the scientific notation for the floats. And we can also have character literals. So car c equals a, or we can define the Unicode version. So you owe three O, six. And let's print this out. Ca, ca. See that. See you. There we go. So this is the Unicode character for the question mark, for example. And we can also have string literals. And we can also have the boolean literals. Let's print them out. So this is the S. And this is going to be the bee. Going to be the bee. There we go. And what we can have are also Unicode escape sequences. So for example, these are the escape sequences that we can use. The Unicode me put them in backslashes. So we can have the bow character, the backspace, the form feed, carriage return, new line, horizontal, vertical taps, single quote, double quote, and the backslash as well. And we also have to talk about underscore. So in my experience, this topic is one of the most dividing amongst developers. One reason for this is that there are those learning C-sharp as first language, trying to follow the best practices and coding style guides. And there are also those who come from different backgrounds, like C, C plus plus Python or whatever language. And they tend to name variables differently. And so of course, each company may have their own like coding guideline or style guideline. And what you can do is to check out the style cop. And also the British Heart. These are tools that allow you to create like a style or verified style guide based version of your application. So that was all I wanted to show you in this video. See you in the next one. 20. C# Advanced Returning read only references from functions: Welcome. In this video we are going to talk about three turning read-only references from functions. So this topic you've all revolves around the type and memory safe code. So we diverge and one of C-sharp released developers could pass arguments to methods by reference. As the time passed and programming change, the word, new challenges arose that forced the new features to be added to C-sharp. With the version seven of C-sharp, two very important features were added. One was the possibility to declare references to local variables and the other was to return by reference from methods. We will build the foundation to understand the two types of arguments. Argument passing. So what is the difference between value and the finance? These are two main types in C-Sharp, and we also have the possibility to define custom types, but it is not in the scope of this video. So via reference types show different performance characteristics if we look under the hood, because the very nature of that implementation where you tabs do not have any overhead memorialize because the data you can store in a specific type like integer string double has a specific type, specific size, and reference types have to added extra fields. One is the object header and the other is the method table. Object header is used by the common language runtime to store additional information and it's basically a big mask. So let's take a look at struct. So public read only struct, one dynamic. And this struct would have the public string, Bob Lake string by name, with the GET. And public double. In fact, ratio with the GET and the public int, initial cases and public double death rate. Now we can have an instance or a constructor for the pandemic. And it would have the string name, double ratio and int and double rate. And now here in the pandemic, we would have the virus name equals the name, the ratio equals to in fact ratio. And the case is, sorry. In fact ratio should be equal to ratio. And the initial case, this should be equal to k is, is, and the death rate should be equal to rate. And we can see that the accessors are read, are only defined with get and the set is missing. And we don't read only keyword is that tell the CRL that our struct is going to be immutable. That means that over time the fields cannot be changed. Now we would like to combine this man, The above mentioned aspect, which is the struct and passing values by reference to create a demonstration for this topic. So what we would like to do is to create this. Alright, so the alignment is good. Public class, simple, ref, read only. And we will have the static int array with the new int three. And it is going to be 123. And the static int get index, int index. And we return the RAF a index. And we would have the public static void for our what. This should be closed. And here we would like to use the cones all that bright line to get index. Hold on. This is where we should put it. Get index first and use the cones or read key. And we can see the value which is one. So in this code, we see a static array of integers with a size of three. And our method GET index is taking an index as an argument and returns an int in a jar from our array, which is radon. If we pass the index which is bigger than the length of the array or smaller than 0, then we get an exception of the index out of range exception. So if we want to create a more complex example, we could do it the following way. So let's say we have struct, which is representing classrooms. So this has the constructor, which is taking a name and the size. And it also has a current utilization private array. And it has a name and the size properties, and so on. So now what we can do is to go ahead and create the following. So we have a very bar which is called rooms, and it's a new classroom. And here we would like to have the new classrooms. Math with ten people. And new classrooms lead to richer with 20. And let's not forget to close it. We can have the var school and it has new classrooms. And the school. That store room is going to take the rooms which will initialize. And then we can use the phones all that right line to print the school that get utilisation. 10. If you run it, you can see the different classroom utilization. And this is basically how you can create your own read-only references to be returned from functions in C Sharp. And technically, that was all I wanted to show you. See you in the next one. 21. C# Advanced Method without a name: Welcome. In this video we are going to talk about methods without a name. So this is a set of features in C-sharp which is very important to understand. This set of feature revolves around lambda, lambda expressions, delegates, and anonymous methods. We are going to see how you can use them. First, we're going to talk about delegates. So typically functions or pause one or more parameters or nothing at all. Usually they return something or perform a specific operations with data or the texts they have. We are talking about delegates when we would like to pass function itself as a parameter. Let's see what C-sharp has to offer. First, we would like to create a delegate. So for example, we would have the public static string Linux server, which has the string name, string state. We would have the check if the state is equal to up, then we return. The server is. Otherwise what we would like to do. If the state is down. Then we can return the server is down. And finally, return unknown state. Alright. So does it work problem with should have it in double-quotes. Great. Fine. Now what we have to do is to create a delegate string state reaction with the string server and the string state. And we have to define the public static string Windows Server with the string name and the string state. And what we would like to do to return the server is in state. State with the dollar sign, of course. And we should move it here inside the program. And here we would like to create a state reaction. Linux equals new state reaction. And we would use the Linux server. And the state reaction Windows, new state reaction Windows Server. And we would like to do the following console, right line, Linux, bind and up. And we would have another Linux which is LDAP and have the following. So now we would like to have this state reaction or just see it in live action. So what is the problem? As you can see, no problem. The server is up, so it is basically working as intended. And yeah, we could further extend its functionality of this stuff with the remote checking or ticket opening if you are in a big enterprise infrastructure, but let's technically it. So now we are going to talk about anonymous methods. So in the previous section, it was discussed how delegates are reference types and used to reference any method that has the same signature. In contrast to them, the anonymous functions are all about parsing code block or code as a delegate parameter. Let's create the following example. Public delegate. Void state, the string state. And in the static void main, what we would like to do is to create the outside scope, which is 99. And the state S is going to be a delegate. And it will be a string state delegate. And basically what we would like to do is to use a console right line. And the state was entered. Let's make it an f string and close the console. Right line. Dollar sign. The value from outer scope is outside scope. And we are going to send D up here. And if we execute it, we should close this one as well. We should see the following. The state upwards and third, and the value from outer scope is 99. So this is how you can define anonymous methods. The last one should be lambda parameters that we check what lambda expressions. It's an anonymous function that can contain expressions and statements. So let's create the following. We will have the function string, string. And it is going to be a welcome name. And we define the return Welcome name. Weight of course, the dollar sign. And don't forget to close it. So now we can use the console right line to print out the wealth thumb. Danielle. If we execute it, you can see that we are using the lambda expression. We could create another example. So int, int n 34 equals x and returns the x times three. And then we can print out the entry 0.5. It should be 15. So that was all I wanted to show you in this video about Lambda expressions, delegates, and anonymous methods. See you in the next one. 22. C# Advanced LINQ: Welcome. In this video we are going to take a look at language integrated query syntax, which is the long version of linked cue. And it was introduced in another dotnet framework with the version 3.5 back in 2007. And the core concept was to extend the framework and along with it, the C-sharp language with query expression capabilities. For example, if we were to create an example, we can create an ArrayList string. And that it contains server list with the new list string. And we would like to have the bottle bell loom domain controller. And prosthetic, which is the DNS. And to key, which is the, the ACP. And basically that's the structure that you could define in the main function. This is how we could demonstrate it. So d c is equal to list, server list, where S, S contains Domain Controller. And let's move it here inside the main. So now we can use the console right line, the printout, the DCs. And as you can see, this is the list of EECS. And it has basically a deferred execution. So in order to dig deeper into linked queue and what other benefits are there to eat, we need to understand what deferred execution is. In most cases during compilation, the link expressions are evaluated on a specific dataset and the variables initialized with the filtered values. By implementing deferred execution, we can save valuable CPU and the RAM resources. Because the concept allows us not to evaluate a specific expression or delay the evaluation until the realised value is actually required. There are two cases when it is very useful. The first is when your application is working on multiple gigabytes of data or even terabytes of data. And the second is when you have chained together multiple queries that result in different manipulations of the datasets. So we have a keyword that we need to talk about. And this is yield. In order to deepen our understanding of the different execution, we need to introduce a keyword called yield. And this was introduced with the version 2 of C-sharp. It is with the Vita for lazy evaluation and improve the performance of LINQ queries. And the keyword yield is context you are, which means that it can be used as a variable name without any problems. So let's create a small application. Here. We would like to have a public class server. And it has a string name and a string function. And we have the public string name with the Get. That is suppose to return the name. And the set, which is supposed to set the name equals value. And we have the same for the function so far, bleak string function. And we use the function, forget answer. Alright. We will also have constructor, so public server. And this constructor is going to take the name and the function. And set function equals function. Name equals name. Alright? And basically that about the server class. And we are going to have another public class, which is the interim program. And here we would like to create public static I innumerable for the server, the server DB. And here we need to define the following. We are going to have a server array with the servers. That is just a new instance of the server. And this instance is going to be populated by the new server or bad loan and domain controller. And we are going to have whatever and wherever. And one is going to be the HCP and DNS. Alright. This is now closed. And what we would like to do is to have the for-each server S in servers and yield return S. So now we have the underscores gone. And what we can do in domain is to use the forEach in Server DB. And simply use the console right line, dollar sign, and use the S dot name and the S dot function. Now, if we execute it, you can see that we have the deferred execution demonstrated and we're able to iterate over the INR I innumerable. And the key here is the yield. So here the return S, which allows us to iterate over each element of our server list. And it does not return the whole list at once to saving know MOD and improving performance. This is also an example for deferred execution. As the for each loop was pulling out the terms one by one. And we should consider difference between Lizzie and eager execution. So or evaluation either. The use of lazy evaluation means that only a single element of the source collection is process during the call to the iterator. So something like this. And an iterator can be accustomed class or a foreach or abide loop depending on the context. And that was all I wanted to show you in this example. See you in the next. 23. C# Advanced String interpolation: Welcome. In this video we are going to talk about string interpolation. String interpolation has something to do with printing to the console. And it is basically a common task. We may print a simple status message, the outcome of a specific action. It doesn't really matter. What matters is how flexible our printing statements are. And it also matters how it fits into the programs flow. For example, we should consider the following. So string interpolation can use three types of variables, substitution, array access, expressions, and method calls. The most important aspect of string interpolation is the dollar sign character. So for example, string where, where it should have score and string what? Tomato. And you could use the console dot write line to print out. I bought in and use the console dot write line, not right line, console, read T. And if we run it, you can see that these variable values were nicely interpolator. And basically what we can do is to interpellate arrays as well. So let's create an integer array which holds the even numbers 2468. And now we can use the console dot write line that politics. So the first, second, third, fourth are even numbers. And there we go. This should be the first, and this should be even numbers. Alright, so now the output seems to be just fine. What we can do is to also interpellate expressions or intercalate with expressions. So we have two values, x, x equals eight and y equals ten. We could use the following to print out a nicely formatted output. So X plus Y equals X plus Y. And we could times divide and maybe the minus. And if it is acute this example, we should see the following on the output. So you have the option to evaluate expressions when you are interpolating. You could also create a function which will have the static int fourth power int x. And it should return x times x times x times x. And here on the console. And we could write x to the fourth is fourth power x. This way, we interpolates the function call itself, and we can also interpellate with alignments. So let's create workers variable, which is a new dictionary of string and string. Here, we could say that we have the John though, equals to DevOps. Though, John equals to level up to add. Here, what we can do is to use the console right line. The printout that we have. This should be the minus 15. And we should help the position with the 20. And use the for each loop. In workers. Here, print out the title key. And the title value should be a capital K, K. And if we execute this, you can see that we have the pacing here. In this. Hold on. It should be like this. Looks better. So that was all I wanted to show you about string interpolation. See you in the next one. 24. C# Advanced Value and reference type assignment: Welcome. In this video, we are going to talk about an interesting topic in C-Sharp, and it is called value and the reference type assignment, so well and graph. So let's create the project. So based on the type system of a programming language, there are two main categories. There are strongly and weakly typed programming languages. And these categories defined how typing rules applied during compilation and runtime of the source code. In 1974, Barbara Liskov and Stefan zeros defined a strongly typed programming language the following way. Whenever the object is passed from the calling function to call function is its type must be compatible with the type declared in the code function. So we're going to give some context and take a look at how and what's the difference between them. So in the dotnet framework and touch the c-sharp programming language, there are two main types. One is called value and the other is a reference type. That is another term called contexts. And there are two contexts in C-sharp. One is called safe and the other is called unsafe. We will explain this later, but it should be mentioned that in an unsafe contexts, we have a third type called a pointer. For now, it's enough, we know the context safe when the context is safe, when the code is running under the supervision of the CLR. There are four types which fall under the reference type category. Strings, array, classes, and delegates. And the rest of the types for fall under the type category. So bool by car, decimal, and so on. Let's take a look at value type. So let's say we have a function, public static, void squared it. And it receives a double as an argument. And what we are going to do is to use the console right line and basically x times x. Now we can declare a variable a, which is Stan, and use the console. Or rather just simply call the double square it a. And let's give it a console dot read key. Now if we execute it, we should see the output as 100. So what happens behind the scenes? The value of this content is allocated on the stack and a single space in memory based on the type is reserved in the mammary, this variable directly holds the value. So if we were to copy this value to another variable and assignment, the value is copied. So you will have the value of these results twice, twice on the stack for each variable. Every predefined data type in arms and even structs. Or this way. The value types are created at compile time. Because of this, they are protected from the garbage collector. It cannot access them. Now let's take a look at the reference type. So let's say we have a public class server. And this server is going to have a string name, public and CPU and public in RAM, or just make it double. So now what we could do is to create the public and void initialize. And we are going to have a category and the server S as arguments. So in case the category is small, then what we would like to do is to create or rather assign the type small. And what we would like, sorry. Public string type. So as the type should be small, as the CPU should be one and S, the RAM should be two. As if the category is medium. Then we will assign a little bit more more resources and call it medium. Let's see two cores, four gigs of RAM. If category is big, then we would like to assign the big four CPUs and eight gigs of RAM. Otherwise, we would like to throw a new exception. New system, that argument exception and category must be small, medium, or big. Alright? So now what we can do is to create a server. Server is going to be a new server. We can call the initialize. Hold on. It should be this way. Square it. Why is it not working? We have this. We have the initialized server. And it should be close to here. So initialize server and a logo and it's already defined. So let's make it be and square a. So there is no argument given the initial server. So let's make it small. And Lee. So we have the string and the server S. Why is it not public class reference type. And we have the server here, and string and programs server. So we have the small medium and we have the server S, public static void. Great. So now what we should be able to do is to use the cones console right line with the dollar sign and just show the attributes. So be cpu, type and B that Graham. And let's divide them. Alright? So basically that's it. We have a class which is of the reference type. And this is important to note because the function called initialize server, which is initializing, takes two arguments. The first one is a value type and the second one is a reference type. The type which is where the class is past, the function will change the public properties of the class pass by reference based on the category. We pass. If we pass a category which is not implemented than a new ad or his throne. So that was all I wanted to show you in this video about value and type. See you in the next one. 25. C# Advanced Null propagation operator: Hello there and welcome back. In this video we are going to talk about the propagation operator in C-Sharp. So back in 2016, there are lots of things happening. On the 12th of November, there was an event called Visual Studio connect head by Microsoft on the cylinder is released preview version of Visual Studio 2015 and the C sharp version six. This new version has incorporated many changes that developers and the technology of that time required. Just to mention a few of these features, that was the read-only auto property is auto property initializer expression, BUT IT function members using static and the newer conditional operators. So in this guide, we will take a look at the conditional operators, or as more commonly referred to as propagation operator. There are also folks out there who refer to this feature as safe navigation operator. In order to understand it, we need to introduce two new operators. The main goal of these operators to make code execution more fluid and replace the null reference exception with meaningful add or handling. So let's see an example for the member access operator. Before the c-sharp. C-sharp, the below code would have resulted in no reference exception. So we have this intern or crass. We have the static void main. So basically this is the code. And yeah, we have a server and that's it. So now what we would like to do is to overcome this issue and we can do it the following way. So we are going to have public class server with the public string name, which has a getter and setter. Now what we would like to do is to initialize it. And we will have a server array, which is going to be called servers. And we will have a server array with five servers. Now, what we would like to do is to have a server, S1 will the new server. And the S1, that name. This is going to be first. We are going to have a server, S2. And S2, the name is going to be second. Now what we would like to do is to assign into the servers and the servers. Second. And then go ahead. For each server S, N servers. And simply use the console dot write line S, that name. Alright. What is the real key here is that now if we execute it, we should see the following output. So basically we need an array of five or in this case two elements. And the survey will be filled with servers, will have their name property as well initialized. Then we iterate over the server and check with the member access operator if the service name or initialized. Okay, Now you may wondering where the demonstration of element x, this operator is. And we can easily convert the loop the following way. So if we comment this out, we could use the console right line and simply say that servers question or let's just not do it this way. But throughout. This way. For int I equals 0, I less than two I plus, plus. And here we would like to have the servers question mark, question mark, name, double question mark, and say that no name was specified. Now let's let it run for five. Oh, what's the error? Oh, I need to close it. Alright. So this is not set to an object. Alright, let's convert it. So this is basically the demonstration for the neural propagation operator. This is the syntax for that, and this is how you can use it. And that was all I wanted to show you in this video. See you in the next one. 26. C# Advanced Clojures and lambda expressions: Hello there and welcome back. In this video, we are going to talk about closures with lambda expressions. C-sharp, the capability that allows a method or a function to reference the non-local variable, what values is called closure. This feature is commonly utilized in conjunction with lambda function, which are nothing more than anonymous function that developers utilize over main functions to provide a way of flexibility. Let's talk about non-local variables first. So in C-Sharp, accessing a variable outside the scope of a function is possible. And consider normal variables x as this way are called non-local variables. If you, you may also hear developers referring to this type of Fourier, but as captured very able. And basically, what we could do to demonstrate here is the following. We have a static string, best, a quasi linear, and we have a static void. Foo is the best. And we could say that we want the console that right line to print out. Best is the best. Alright? And we should move this hole here. What we could do is to use the console dot read key and call the who's the best function. This is basically what captured variables look like. And what are the lambda functions. We already had a video about lambdas, but let's try to reiterate it. So there is lots of articles about lambda and them being closures. And some people tend to agree some way that there are, but they are only part of the truth. And I believe India, like the opposition party, Lambda functions may be implemented as closures, but they are not closures themselves. This really depends on the context in which you use your application or the environment. When you are creating eating a lambda function that uses no local variables, it must be implemented as closure. So lambda expressions can take two basic forms, expressions lambda and statements lambda. So for an exception expression lambda, we could give this example. So it takes two Boolean values and checks whether they are equal. And we can have statement lambdas as well. And they look something like this. So now we have a string and then it would welcome that string with the message. So we should note how closing the curly brace also ends in a semicolon. When we work with statement lambdas, we usually create multiple expressions, encapsulate them inside our function. What we would like to do is to take a steep turn and combine lambdas and closures. So we have public static partial class closure, demo. Here. What we would like to do is to create the public static void. Outside. This is going to be our function. And inside the function, we will have a North local variable. And it says that closure based lambda. Now we will have the funk, string them all. And we would like to use it as a Lambda. And we will have the string local. This is Lambda and the return local Plus. Alright. After that, we will have a string message, which is demo. And we would like to use the console right line to print the message. And in domain, what we could do is to use the closure demo that outside. And that's it. So let's run it. And here we can see how this was demonstrated. So we see in this example that are non-local variable did not change. However, the situation might not be always true. If the variable changes, the referencing function will be impacted. Sometimes this is exactly the case we want to achieve. For example, we could have a function that logs in terminal change in a function state with a Lambda function. That way, each change of the state would result in a different logo. So now we can demonstrate it with closures, and here is how we would do it. So we will have a foo variable, which is stem, and the function which is called bar. And it just simply returns for console right line. And we would use the full bar. And we can change the value of foo to 20. And after that, we will have a fighter which is equal to bar. And we could use the console right line to print out fighter with the fighter. And this is how we could implement closures. And technically that is all I wanted to show you in this video. This is how you can use closures with lambda expressions. See you in the next. 27. C# Advanced Foreach and enumerators: Hello there and welcome. In this video we are going to talk about understanding generators and enumerators. And I enumerator in C-Sharp. So one of the concept is called generators, the other is iterators. We're going to inspect how these ideas are incorporated in C-Sharp and check how you can utilize them from for our own advantage. A generator is usually a function or a special routine implemented in the language which controls the behavior of a loop. The generator beers a eerie resemblance. Two functions which return an array. They have parameters and can be called to generate a sequence of phi times. Without generators, let's say we have a function which returns a list of integers about 1 million at a time. This means the needs, the list needs to be built up in memory, allocate space for all the values, and then pass those values whenever they need to go. If we have the resources, it's fine. But people always strive to figure out something for these kinds of problems. And generators were born. And the iterators are like the counterpart for the generators. And the concept dates back to 1974. To the C programming language. By design, an iterator should allow the programmer to traverse specific containers, and it's most commonly used for lists. So let's see an example in implementation, we have a list of strings to be iterated, which is a new list string. And to be iterated has an add function. And we can say that programming is fun. Now, we can convert this list to a generator very simply. We could just simply say that it's an I and numeric string. And basically we need to change it this way as well. So I enumerate bow, string and hold on. We have this one. And this should be the to-be iterated. And we need to change the other one as well. So I bow to be iterative. And what we can do now is to take the for-each loop and say string element in I innumerable and use the console right line element. And if we go ahead and read key to wait for the output, this is what we are going to see. This way, we have changed the list to a generator, so it has a smaller memory footprint. And here, basically there is no break statement. And yet it does not go infinite, so it knows how to stop when we like as exhaust the list which we would like to iterate. And we can see the tea take a practical or more practical example as well. So we would like to create small app which can process the numbers if they are odd or even differently. The eye enumerator provides us an elegant solution, which is, involves two static methods. So the first static method would be this one. And we're going to need to use the system threading. And what we would like to do is to have the audit process so as well. So even process what process. So there we go. So what happens here? We take an eye numerator as argument. And if the current is 0, we say that the list was processed exiting than wait for five seconds. If it's modulo two, then we say that the number is even calling processor. And there we go. So this is for even and the odd numbers. And now inside our main, what we can do is to create a list int, which is called MyList. And this is a new list of integers with Dan values for I goes from 0 to I, less than ten I plus plus. And we would like to use the my list dot add to add new elements. And after that, we will have the eye enumerator. And this is going to take an integer. My list in m equals mylist, get a numerator. My list in num, move next. Process or mylist the num, and that's it. So let's give it a go. And as you can see, the output shows that the list was processed exiting. So this is how you can use for each eye enumerator in C-Sharp. See you in the next one. 28. C# Advanced Static vs instance members: Welcome. In this video, we are going to talk about how you can distinguish static and instance members. So object-oriented programming revolves around two main terms in. One is object and the other is instances. There are different theoretical ideas that the specific programming language implements. In this guide, we will take a look at a static and instance members. We will decide the terms and what they're all about, how you can utilize them into some very simple rules. So we distinguish also three types of different numbers. We can have static fields or properties, static methods and static classes. So let's start with the classes. What's, what's with the static and non-static classes are classes are either static or non-static. And we have non-static class. It can contain methods, properties, and even events. And you can call this even without instantiating the class. So for example, let's create a project for that. There's this non. So for example, let's create a class which we would call non static. And here we are going to have a public static string, no instance. And on the console dot write line, we print. I don't need to know. Dan Shi a shown. Hold on. We should be returned. Alright. And what we can also do is to inside our internal class, we define our public string. Another instance. And here we return no instance here. Either. If you go to the main, after having the right key. What we can do is to use the console right line, the printout, the result of the function from the non static no instance function. And also the console right line. And another not like that. So basically, if we execute this example, you will see that we call the function of the class without instantiation. Without using the public modifier, we can call the knowing stars from the non-static, static demo class, and we do not inherit anything from that in our main class. And you should also know the public keyword when we invoke another instance from the method from within our main class and accessibility level is correct this time. Basically. In another wording, when we talk about the instance members, we talked about those members of class that cannot be called accessed without instantiating the class. Those that can be accessed are called members. So for example, if I give this nonstatic public string number equals whatever, then we can access this one. So what about static methods? So for example, if we have this example, this is going to be called a static members, a static method. And when you define a static method, we allow access from that method only to static members of the class and we cannot access instance members. And if I was to access this member variable from the static method, it would still work fine. So now we have to talk about static properties or fields. So when we have a static field, we need to keep in mind that this field identifies only one storage location in memory. And no matter how many instances we create that will be only one copy of a static field. More often than not, as a result of the natural of their nature, static properties are used to store data which is meant to be shared by all instances of the class. And if you want an example for that, we can create a class called counter. Here we would have the public static int down Cs equals 0 and public counter. What we would like to do is to use the instances plus equals one to increase the instance counter. And when we go ahead and create a new instance from the counter, what we can do is to use the console right line. Print out the number of instances. Here, what we will do is to use the counter class number, or rather instances to print out the number of instances. Currently if we execute this solution, we will see one. But if you create a few more instances. So let's say this is count 123. And if we are to print out the new instance count, we will see that we have a total of four instances. And basically that's it. So this is what I wanted to show you in this video. See you in the next one. 29. C# Advanced Type inference: Hello there and welcome back. In this video, we are going to talk about typing financing c-sharp. C-sharp is strongly typed language. Is it for a declaration is called explicit. And this means that we have to specify a new variable. Otherwise the compiler will throw an ad or with the version three of C-sharp, a new keyword was introduced, and it is called voir. And this allows developers to store any type of value in an implicit way, meaning that the compiler will decide for us during compile time when we ran the first assignment happens what to become as a type of that variable. And it can be easily integrated with link Q, which is the language integrated query. Before the introduction of type inference, explicitly defined what is going to be a string or integer or whatever before compound compile time. So we define a string with the default value and so on. And now we have to talk about link q. So q stands for language integrated query. It is a set of technologies based on the integration of query capabilities directly into the C Sharp language. It is very similar to query's. And the goal was to filter out data based on specific criterias and supports most of the datatype Slack, sequel, Zemo, and so on. And we are going to create an example which is supposed to demonstrate just that. So let's create a public class server. Inside the public class, we will have a public String name, which has a getter and setter. And we will have a public String operating system with the getter and setter. And after that, what we would like to do to create a new solar. And this is basically not just a new server, but the list of servers. And we would like to have this as a new list of server. Here. What we would like to do is the following. So we want to instantiate these servers. Come on. And we have a new server, which is going to have a name, which is like, what about loom and an operating system, which is going to be when? 2019. And we will do some more. So big boy. This is going to be a CentOS eight and Ricky model, which is going to be, that'd be nine. And now what we can do is to create a server query, which is going to be from the server in servers. And we would like to have the server OS filtered to the IBM nine and close this. So we have this list and we have to add the select new server, the name server OS, and just close it. And after that, we can use the foreach var server, server query and simply use the console right line server. And let's give it the cones are about three key and run it. Now, as you can see, here, we have the filter result. And what do we see here? We are using two additional namespaces. One is called generic and the other is linked queue. And the first provides us with the implementation of the list data structure, where we store our servers. And the second ads, the link capabilities to our application after the initialization of the list with the servers. And this is where the magic happens. So first we define our variable which holds the query is arts, and then the query is done. Which looks for servers cheaper than or not cheaper them, but rather the operating system being WAN 19. The walk keyword allows us to decide the type of the body during runtime. And technically that is all I wanted to show you in this video. See you in the next one. 30. C# Advanced Local functions: Hello there and welcome back. In this video, we are going to talk about local functions in C-Sharp. So the local functions, this feature has become part of C-sharp with the version 7. And the idea behind this feature is the definition of a function. We did another function. And it is similar to how Python decorators work. If you are familiar with the concept and if you would like to rephrase it, we could say that the local function is a private function of a function and its scope. And it's limited to the function within which it was defined. We will dissect this topic further in this video. So the type of lookup function bares resemblance to the type of the container function. However, there is no strict rule enforcement from the compiler side. And when we have a local function, we can use async and unsafe modifiers as well. So unsafe refers to C-sharp pointers at async is referring to asynchronous. And common places where local functions are defined. Our methods constructors, property access source, event accessors, lambda expressions, phi analyzers or destructors and local functions. And a very useful feature of local function is that they allow exceptions to surface immediately when we are using iterators, for example, exceptions are only surfaced when we enumerate them. So let's create a small demonstration. Here. We would like to have a void message, string, say. And we use the console. Right? Line. Say. Let's use the cones or read key to acquire input. Now, what we would like to do is to say the message, welcome. And if we execute it, we should see the following output. Now, this is basically the simplest form of local functions. In our case, we have the function called message, which takes a string as an argument and outputs to the console the message. And let's create another demonstration with variable scopes. So for example, we have here int k equals 11 and the double j equal ninety-nine point nine. And we would have the void scope. And we use the console right line to print out the name. The value of name of. This should be an f string. And we would pass two arguments as well. So in X into Y is X and Y. And we would like to use the K and J as well. Come on. K and J. J and K. And we don't need that name. Actually, we needed that. So now what we would like to do is to use the scope. Let's make this a string rather than 1299 and just execute. So as you can see here, the local variables called k and j are accessible for the function as they are defined inside the container function. And what we would like to do is to create a generic function. So void generic function. And we will have the value with the value X. And let's go to this one. And we would have the cones on the right is equal to this one as the previous. And we will call this function. Nine, 11 that if you run it, the value of x is 11. Generic functions combined type, safety and efficiency. And they are often used with collections and methods which operate on them. And we can also reference the outer parameter in local function that are declared in the same scope. So for example, we could create the void my string x out string S. And S is equal to dollar sign. This is the one. And now we would have the string message equal to null. And we would have the My out 12 and out message, the function call, and simply use the console that right line message. So now we execute it. You can see that the value of x is 12th. The atmosphere is variable, captures the message and works in tandem with the string as argument of the function. And we could use also the params keyword void, my forearms, firearms in array. And cones. Got the bright line. And here we could say that got the number from the pipe line. And we would have element. And for each element in array. That way, our for loop looks good. And we would have the test, which is a new integer array that has the 123456789. And now we can use the bottoms yesterday. And there we go. So basically this is how you could use local functions in C-Sharp. See you in the next one. 31. C# Advanced Custom event accessors: Hello there and welcome back. In this video we are going to take a look at how you can write custom event accessors in C-Sharp. So in order to understand customer event axis, so we need to clarify why they are needed and the use cases. Here we will introduce the concept of events and take a look at the events and the accessors which can be used to interact between classes. And what are events. So let's take a lively example. We have a graphical user interface which consists of buttons, text, boxes, labels, and so on. Each component is made up of their own class. Each class provides functionality. For example, you can type in the text box, click on a button, and so on. And we categorize classes either by publishers or subscribers. The publisher is a class which sends or raises the events. And the subscriber is the one which received the, receives the event based on its specific actions. So there are some rules for the events. The publisher determines when an event is raised, the subscriber determines what action is taken when a specific event is fired to which it is subscribed. Event with our subscribers are never raised. And events mostly get fired due to user interactions either on web application or graphical user interface. By default and event has multiple subscribers and gets it handle handlers invoked synchronously unless defined in an asynchronous asynchronous fashion. The events are based on event handler, delegate and event logs base class. In order to create an event, we need to create a delegate which holds the details of the subscribers to an event and create a public event that is externally visible to a class and used for creating subscriptions. Then we create the method in a class which will fire the event itself. So for example, let's do the following. Let's call this public Class a machine. And this public class machine is suppose to have something called private int utilization, which is going to be 0, private int safe utilization, which is going to be utilization level under which the machine is safe to be operated. And we will have a public delegate. Void stress limit x c did event handler, which will have the object source and the event args E. And we will have a public event stress limit exceeded handler. We will have a public we're to void on stress. Level. C did event args E. And basically what we would like to do is to have stress limit exceeded question mark that. Invoke. This E. Let's bring it down here so it's more visible. And we will have a public int, four months, which will have the getter. And it will return utilization. And we will have the static void. Machine. Stress will limit x c did object, source event args e. And we would like to have the machine, which is equal to machine source. Ones. All right, line. Stress level warning. You would like to have the Mac are both bad for months and the person sign. Now what we can do is to create the public void stress test, int utilisation. And now we would like to, I have the old utilisation equal to underscore utilisation. And underscore utilization should be increased with the new utilization. And if the old utilization is less than equal to save utilisation and utilization is greater than safe utilization. Then we can call the on stress level exceeded new dogs. Alright, so basically this is going to be the stress test for our class. And in our main function. What we can do is to create a new machine. And we can odd new stress limit event handler to the machine. Stress limit. Come on. Z did. And we would like to use the poems on that right line to say that the utilization is, this is going to be an f string machine that bad form ions with a percent sign. And we can use the machine. That stress test. Let's say this is going to be 60. We will write out the utilization, then create another stress test for the fifth. And let's make the 75 and use the forums or agreed to wait for the prompt. Now, if we execute this example, you can see that the utilization is not going to change. I mean, it is going to change, but once we have exceeded the utilization, then we get the warning so that custom event is raised. So this was basically an example which shows you how you can write your custom event accessors in C-Sharp. See you in the next one. 32. C# Advanced User defined conversions: Hello there and welcome back. In this video we are going to talk about how you can write custom user-defined conversions in C-Sharp. It's gone those conversions in C-Sharp or every day of pedestrians to most developers. And we use it to verify inputs solid defied the workflow of our application. They are built-in convert, that are built in conversions, and supporting facilities in C Sharp that allow you to maintain flexibility and consistency throughout your application by default, there are two main types of conversions. One is called x plus c, The other is implicit. C-sharp also provides a way for you to define your own conversions. Let's take a look at explicit conversions. So for example, we have a float Pi, which is three for F. And we have a double B pi, which is going to be by. And we can use the console right line, the printout by d pi. Let's take a look at the output. So as you can see, in the first case, we have the three dot 14 as value. And the third one. The second case is a little bit longer. So basically, what we see is how float is converted into double. That is the difference between the precision. That's why we see different values. And what we can also do is to basically go ahead and let's call this E pi, d Pi. And here we just tell that we want to have a double value. And this is going to be the three that 14. And we would like to create a float version of it. And F DEP. What we would like to do is to use the float on the d, d, p, y. And now we can write out these values. Let's execute our example. Now, as you can see, we have used the explicit conversion to create the new values. Now, what we can do is take a look at how you can define your own custom conversions. So for example, we have the public class called conversions. And we have the public class custom type. And this one is going to have a public int number with its getter and setter. The public bool, magic, getter and setter. And we will have a static int operator, custom type int value. Inside this function, we would like to return a new custom type with the number equals value. And the magic, it was false. And that one public Boolean operator, sorry, n. After that, we can define our static public X bulleted operator, int, custom type, magic. And we would like to return from the magic number. Alright, now we have our own class and we can create an integer which is called a number. And it's going to have the value three. After that, we can create a custom type magic equal to a number. And we can use the console right line to print out from int a number into magic with value magic number. And if we close this line and execute it, you can see that we have converted the integer three to a user-defined conversion, which has the value of three. So that's technically how you can create your own custom user defined conversions in C-Sharp. See you next time. 33. C# Advanced The End: Welcome. This is my final video of this series. Here in the series, you have learned many useful techniques in C-Sharp, how you can enhance your application, how you can implement advanced features which are going to allow you to build more robust applications. We have seen throughout many examples how you can utilize all the arsenal that C-sharp has to provide you in order to make your programs or applications more successful. And all these examples are going to be uploaded in a GitHub repository that you will be able to clone and reproduce the examples that you see throughout the videos. See you in the next one. And I hope this has been informative for you. And I would like to thank you for watching. Bye.