C# extension methods with examples | use of [extension methods] in LINQ

In this article, we will discuss about the extension methods in C# with multiple examples.

C# extension methods
C# extension methods.

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.

Continue reading “C# extension methods with examples | use of [extension methods] in LINQ”

Object oriented programming tutorial | 4 basics OOPs concepts

In this article, we are going to talk about object-oriented programming and its 4 basics OOPs concept in C#.

Object Oriented Programming OOps
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.

What is a class in C#?

Continue reading “Object oriented programming tutorial | 4 basics OOPs concepts”

What is Indexer in C#? Difference between Indexers and Properties in C#

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#.

C#-Indexer
Indexers 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 [].

Continue reading “What is Indexer in C#? Difference between Indexers and Properties in C#”

SQL Delete Cascade – SQL query to delete parent-child referenced rows

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.

SQL-DELETE-CASCADE
SQL-Delete cascade rule

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.

Continue reading “SQL Delete Cascade – SQL query to delete parent-child referenced rows”

SQL Comparison Operators (Less than, Greater than, Equal, Not Equal operators)

 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 ;

OperatorDescriptionExample
<Less Than (<) OperatorX < 10 (returns true)
>Greater Than (>) OperatorX > 10 (returns false)
<=Less Than or Equal To (<=) OperatorX <= 10 (returns true)
>=Greater Than or Equal To (>=) OperatorX >=5 (returns true)
=Equal (=) OperatorX = 5 (returns true)
!=Not Equal (!=) OperatorX != 5 (returns false)
<>Not Equal (<>) OperatorX <>5 (return false)
SQL Comparison operators

The following are the examples of the above SQL comparison operators.

Continue reading “SQL Comparison Operators (Less than, Greater than, Equal, Not Equal operators)”