In this article, we will discuss about the extension methods in C# with multiple examples.
What is the extension method in C#?
The extension method was introduced in C# 3.0, Which allows a developer to add new methods in the existing class or structure without creating a new derived type, recompiling the code, or modifying the original type.
When to use extension methods in C#?
In C#, extension methods are very useful when we wanted to add a new method in the existing class or struct which already contains few methods but we don’t have the source code or permissions to do changes in the existing type.
Let us discuss this concept with the help of the following example.
In this article, we are going to talk about object-oriented programming and its 4 basics OOPs concept in C#.
What is object oriented programming?
Object Oriented Programming (OOPs) refers to the programming languages that use classes and objects in the code, that has certain properties, methods, fields, and events. OOP is used to structure a software program into simple, smaller, and reusable pieces of code (generally called classes), which are used to create individual instances of objects.
In simple words, we can say that any programming paradigm where data or everything is represented as an object is known as a pure object-oriented programming language. OOps allows us to develop modular programs and assemble them as software applications. It allows data hiding, reusability, and extensibility of code.
In Object Oriented Programming (OOPs), the programs are organized around classes, objects and data rather than action and logic.
There are many object-oriented programming languages including C#, C++, Java, Python, and Ruby, etc.
In this article, we will learn about the Indexer in C# with multiple examples. Also, we will see what are the major difference between the Indexers and Properties in C#.
What is Indexer in C#?
Indexer in C# is a smart property that allows an instance of a class or struct to be indexed as a virtual array. An indexer can be defined the same way as a property but the only difference is, the indexer can be defined using this keyword and square brackets .
Indexers will make a class behave like a virtual array. We can start accessing the data members of a class with the help of the index position. Index position can be an integer, string, char, etc.
Syntax to define Indexer in C#
Following is the syntax of defining an indexer using this keyword and index operator .
In this article, we will learn DELETE CASCADE rules in SQL Server with foreign key constraint having multiple examples.
OVERVIEW – SQL DELETE CASCADE
1. DELETE CASCADE : In the SQL server, when we create a foreign key using the delete cascade option, it deletes all the related rows from the child table when the referenced row is deleted from the parent table having primary key constraint.
The following are the SQL scripts that create a parent (Departments), child (Employees) table, and a foreign key on the child table without the delete cascade rule.
Introduction : In this SQL Operators article, we will learn all about SQL Comparison operators in details with multiple examples.
SQL Server Comparison Operators
In SQL Server, the comparison operators are useful to compare one expression with another expression using mathematical operators. Comparison operators return true or false based on the comparison. The following are the list of different type of comparison operators available in SQL.
Consider X is the variable and the value assigned to X = 5 ;
Less Than (<) Operator
X < 10 (returns true)
Greater Than (>) Operator
X > 10 (returns false)
Less Than or Equal To (<=) Operator
X <= 10 (returns true)
Greater Than or Equal To (>=) Operator
X >=5 (returns true)
Equal (=) Operator
X = 5 (returns true)
Not Equal (!=) Operator
X != 5 (returns false)
Not Equal (<>) Operator
X <>5 (return false)
SQL Comparison operators
The following are the examples of the above SQL comparison operators.