To understand Async and Await, first we need to understand about 'Task'. Task - This is used create thread but it will create thread from the thread pool and not from the computer operating system unlike normal Thread object in c# does. This is used to perform async operations 1. Task<TResult> - This return is used when the async method that returns a value. 2. Task - This return type is used when the async method does not return any value. 3. void - This return type is used for an event handler. We saw that concurrency refers to, in one way or another, doing several things at the same time. That concept of concurrency encompasses parallel programming and asynchronous programming. Parallel programming refers to the use of multiple threads simultaneously to solve a set of tasks. For this, we need processors with adequate abilities to perform several tasks at the same time. In general, we use parallel programming to gain speed. Asynchronous programming refers to the e...
Before getting into Dependency injection, we need to understand about IOC and DIP. Both IOC and DIP are principles or you can think it as rules that are set to achieve loosely coupled design between two classes. These two classes can be thought of as class A called as "PARENT" and class B called as "CHILD". It can be thought of as two project or two software components. These two classes should not depend of each other. I mean to say "PARENT" class should not depend on "CHILD" class to achieve something. Here depend means : inside "PARENT" class we should not create the object of "CHILD" class. Ex: Here in the above image you can see the "PARENT" class is creating "CHILD" class object to achieve something. Hence we can say that "PARENT" class is "DEPENDENT" on "CHILD" class or we can also that "CHILD" class is a dependency class of "PARENT" class. So to make...
ref and out - these are used in situations where some methods required to return multiple values from the method parameter list itself and not using 'return' keyword, where method does not have 'return' keyword. Difference is - 1:ref variables must and should initialize or assigned the values before calling the method 2:out variables must be initialize or assigned the values inside the method. That is before leaving the method. In C#6.0, the out variables must and should be declared before calling the method. But in c#7.0, the out variables can directly declared inside the method parameters c# 6.0 ------- int x , int y; obj.Math1(out x , out y); Here before using the variable it must be declared. c# 7.0 ------- obj.Math(out int x , out int y); Here we no need to declared it before using it in method parameters Tuple c# 6 ======= Tuple - these are used in situations where some methods required to return multiple values from the method, where method does have 'ret...
Comments
Post a Comment