HI WELCOME TO KANSIRIS
Showing posts with label dtt. Show all posts
Showing posts with label dtt. Show all posts

Difference between ref and out parameters

Ref and out parameters are used to pass an argument within a method. In this article, you will learn the differences between these two parameters. Ref The ref keyword is used to pass an argument as a reference. This means that when value of that parameter is changed in the method, it gets reflected in the calling method. An argument that is passed using a ref keyword must be initialized in the calling method before it is passed to the called method. Out The out keyword is also used to pass an argument like ref keyword,.

Understanding Delegates in C#

A delegate is a reference type that holds the reference of a class method. Any method which has the same signature as delegate can be assigned to delegate. It is very similar to the function pointer but with a difference that delegates are a type-safe. We can say that it is the object-oriented implementation of function pointers. There are three steps for defining and using delegates: Declaration A delegate is declared by using the keyword delegate, otherwise it resembles a method declaration. Instantiation To create.