
Here you will learn about Cloning Of Object, Shallow Copy And Deep Copy In C#.


Garbage collector looks for an instance/object which is not required anymore and treats these objects/instances as ready to destroy. Then, it makes a call to the destructor to release the memory and deallocate the resources.

What is Expression Bodied Members?1) Expression Bodied member is introduced in C#6.0 and enhanced in C#7.0. 2) Expression Bodied is a new technique or implementation to make code concise and readable. 3) Expression Bodied makes the type member(Constructor, Destructor, Methods, Property, Indexer) defined in a single expression. 4) Expression Bodied members can only be applied to the below list of type members: Constructor introduced in C#7.0 Destructor introduced in C#7.0 Property get accessor introduced in C#6.0 Property set accessor introduced in C#7.0 Methods introduced in C#6.0 Indexer introduced in C#7.0 The Syntax of expression body definition is:member => expression; where expression should be a valid expression and member can be any from above list of type members.Suppose we have a method or constructor that contain a single expression or line of code. Then In spite of using the traditional way to write code inside a method or constructor code block, we can write them as a single syntax. Those members who can follow this approach is known as Expression Bodied Members.

In this blog, I am going to share with you about Constructor and its types in C#

Null Coalescing Operator (??)1) A syntax used to check null and assign a default value if null2) This operator can be used with Nullable types as well as reference types.3) This operator can be represented as x ?? y. Here, x and y are left and right operand. Left operand(x) can be nullable type while right operand should have non-nullable value. If the value of x is null then the syntax return the value of y else value of x will be returned. Means value of left operand will be returned if its value is not null else the value of right operand will be returned.Why should we use Null Coalescing Operator (??)?There are numerous of uses/advantages of Null Coalescing Operator:1) It helps in preventing InvalidOperationException. 2) It helps in defining a default value for a nullable item as we did in above program.(assigning a default value 33)3) It removes many redundant "if-else" conditions and makes the code more organized and readable.

Nullable Types used to include null as a value for value type variable. It has a lot of advantages and is most preferred when dealing with the database. One of the cons is the complexity and overhead as we have to do null checks more frequently.

Before I discuss passing parameters to a method, and I give a brief intro of the method first

Whenever a program or project is developed, data security and privacy is the main concern for a user before using it. For a developer or programmer perspective, code misuse or access, modification of code/data from unnecessary sources or methods call are the main concern. Encapsulation is one of the way to achieve this.

In this blog, I am going to share with you about 'as' and 'is' keywords in C#.

C# Ternary Operator - In C#, we have a special decision-making operator called ternary operator which is similar to if-else. The ternary operator compares two values and based on it, return a value.

'Struct' keyword is used to create a structure. A structure can contain variables, methods, static constructor, parameterized constructor, operators, indexers, events, and property. A structure can not derive/inherit from any structure or class. A structure can implement any number of interfaces. Structures provide better performance.

Suppose we are creating a program in which we have to use multiple named constants of similar type and on the basis of a particular constant we have to perform some operation. So what we normally do is initialize each named constant with a value. This may require a lot of effort if the number of constants is large. Also the look and feel of the code is not up to the mark. Have a look at the below program to understand more. The program contains months of the year. We have to put lots of effort to assign each month to a value.

In C# programming, a situation may arise when we have to convert a data type into our own custom type or vice-versa. In this article, I am going to share with you about User-Defined Conversion in C#.

In this article, I am going to share with you information about Type Casting and its types in C#.

A pointer is simply a variable whose value is the address of another variable. We can not use pointers directly. To use pointer we need to have a specific block for it. So 'unsafe' keyword defines the scope to use pointers variables. Pointer variables can only be used inside an unsafe code block.

'Dynamic' keyword is used to declare the variable of the dynamic type. Dynamic data type variable can contain any type of value. Type of value contained is checked at runtime. The syntax of Dynamic type is shown below:Dynamic <VariableName> = value;

Object is the ultimate base class of all the classes in .Net Framework. Object type is the root data type that can contain a value of any data type, value type, reference type, user type or predefined. We have to typecast the value before assigning to object type.When we change a value type variable to object type, it is said to be boxing, while when we change an object type variable to value type, it is said to be unboxing.

In some programming languages, we cannot create two methods with the same name inside a class. But as C# is an Object Oriented language, we can have multiple methods with the same name and this is called method overloading. In simple terms, Method Overloading is defined when multiple(more than one) methods with the same name are present in a class but with different parameters. We can have any number of method overloads.

A static class is a class which can not be instantiated. We do not need to create an object of a static class like we did in non-static classes. Members of static classes can be accessed directly using the class name followed by a (.) and class member name. Class Members can be methods, fields, properties, or events. A static class can contain only the static members while a non-static class can contain static members. Also, Static classes are by-default sealed so they cannot be inherited.

Generally, In Methods call, Arguments are passed according to the order of parameters defined in the method definition. So when making a method call, it is necessary for us to remember the order of parameters before passing the value to the method call. If the number of parameters is large then it is difficult to remember the order. To overcome this, Named arguments are used. When calling a method, arguments are passed with the parameter name followed by a colon and a value. In Named Arguments, we do not require to pass the parameters in order as defined on method definition, so we can pass the arguments in any order on method calling.

Namespace is used in C# programming in two ways:1) .Net Framework uses namespaces to use its various classes. This can be achieved by using "using" keyword.2) Declaring our own namespaces can help control the scope of class and method names in larger programming projects. Use the namespace keyword to declare a namespaceNested Namespace is defined as namespace inside namespace

Optional Arguments are the arguments which can be omitted if we do not want to change the default parameter value. Optional Arguments are defined at the end of the parameter list. There may be any number of Optional Arguments in a method.

Common Language Infrastructure is a standard developed by Microsoft that allows the use of multiple different high-level languages on different computer platform without being rewriting the code for a specific architecture. In simple terms, Common Language Infrastructure (CLI) enables an application program written in any commonly-used programming languages to be run on any operating system using a common runtime program rather than a specific for every language.
DevSocialUpcoming · 3rd editionAI Agents ConferenceNov 23–27, 2026Live onlineMembers only16days leftRegisterMembers onlyWrite an article and earn +1,000 SHARP when it is approved.
Write an article