Lambda Expressions

Introduction In the earlier post, we talk about anonymous methods, we had seen that by using anonymous methods, we can define a method without providing a name to the method, in addition to it, we were also not required to specify the access specifier and the return type of the method. Lambda expressions are a further shortcut to writing anonymous methods. To understand more let’s … Continue reading Lambda Expressions

Func, Action & Predicate – Generic Delegates

Introduction In an earlier post, we have discussed delegates, multicast delegate. In this article, I am going to discuss the Generic Delegates in C#. In .NET Framework 3.5, C# introduces Generic delegate which allows to invoke the delegates without defining the delegate instance. To understand the Generic Delegates, we should have the basic knowledge of Delegates. I would recommend checking earlier posts related to delegates, … Continue reading Func, Action & Predicate – Generic Delegates

Delegates

Introduction When a head of state dies, the President of the United States typically does not have time to attend the funeral personally. Instead, he dispatches a delegate. Often this delegate is the Vice President, but sometimes the VP is unavailable, and the President must send someone else, such as the Secretary of State or even the First Lady. He does not want to “hardwire” … Continue reading Delegates

Extension Methods

Introduction Extension Methods allow user to add additional feature or methods to existing class without creating a new derived type. Before diving into extension method, lets understand why we use extension method in c#? Example Suppose that there is a class with n number of methods, and you want to add more methods into it. you can add Extension methods using below two approach: You … Continue reading Extension Methods

Exception Handling in C# – Part II

Introduction In the previous post, we have covered basics of exception handling, the purpose of exception handling, types of error, list of system exceptions, and some examples of run time error. In this post will cover ways to handle the exceptions in C#, multiple exceptions catches and writing custom exceptions below is the index: How to handle Exception in C# C# provides built-in support to … Continue reading Exception Handling in C# – Part II

Exception Handling in C# – Part I

Introduction Exception handling is handling known or unknown errors from the program. So, when any error occurs then the program should recover gracefully from the error. In computing and computer programming, exception handling is the process of responding to the occurrence of exceptions – anomalous or exceptional conditions requiring special processing – during the execution of a program. Wiki The basic purpose of exception handling … Continue reading Exception Handling in C# – Part I

thread.sleep, thread.sleep in c#,thread.sleep in c# console application, thread.sleep in c# windows application, thread.sleep in c# not working

Why you should avoid Thread.Sleep

Introduction Thread.Sleep allows user to hold or suspend or block the current thread execution till a predefined time. it is implemented in System.Threading.Thread.dll assembly. It has two overload method C# Source code to demonstrate thread sleep Why you should avoid Thread.Sleep Thread.Sleep required hardcoded sleep time value, which is not a good idea at all. In multithread applications, handling a race condition using Thread.Sleep is … Continue reading Why you should avoid Thread.Sleep

Passing by Value vs. Passing by Reference 

In earlier post we have seen how value type and reference type variable instances behave differently when create copied variable and changing copied variable values. Pass by value Pass by value means you are making a copy in memory of the actual parameter’s value that is passed in, a copy of the contents of the actual parameter. Use pass by value when you are only … Continue reading Passing by Value vs. Passing by Reference 

Array vs ArrayList

Array: An array is a collection of similar data types that can be accessed by index. Array allocates then static memory with consecutive section of memory blocks. ArrayList: ArrayList is a collection of objects of same or different types. ArrayList size can be dynamically increased or decreased as per the requirement. Here is difference table of Array vs ArrayList Array ArrayList Array stores a fixed number of elements. ArrayList is dynamic … Continue reading Array vs ArrayList

Access Specifiers in C#

Introduction Access Specifiers are the keywords that specify accessibility of the object. In other words, access Specifiers define the scope of the user-defined type and its members, i.e. we define who can access the class and its members. As this topic needs at least some basic understanding about object-oriented concepts, so before going through this post you must visit the object-oriented concepts C# provides us … Continue reading Access Specifiers in C#

Control structures

Introduction C# Uses control structures are like flow controller based on the condition it controls the flow of a program. In other words, a control structure determines the order in which the program is executed. Control structure can be put in the following categories: Conditional structures – Conditional structures allow the program to choose different paths of execution based upon the outcome of an expression … Continue reading Control structures

Bitwise Operator’s

Introduction Bitwise Operators always scared developers (with no offence) but once developers understood the power of it, developers love them. Bitwise operator are very powerful operators if understood correctly. Its operators on ints and uints at the binary level. This means they look directly at the binary digits or bits of an integer.  Types of Bitwise Operator Bitwise AND (a & b) Bitwise AND is like logical AND in … Continue reading Bitwise Operator’s

Get Started with C# -II

In earlier post we talk about C# & visual studio installation. Hopefully, you have installed the visual studio on your machine. Let’s create a first console application For making a console application in Visual Studio by using C# as the programming language, perform the following steps (These steps are for Visual Studio 2017 professional version. For other versions, these steps might differ) : Open Visual … Continue reading Get Started with C# -II