90+ benefits of meditation you never know!


I will explain to you the top 90 health, mind, and spiritual benefits of meditation that you never know in this article.

Whenever you heard about meditation, You might be thinking about the monk, who has a long beard and meditating in the Himalayas or Jungle.

You might be thinking that meditation is not for normal people and only for Sadhus (Monk), who stays in a cage and doing meditation for several years.

You do exercise to be physically fit and healthy.

You can achieve your goal in your life also, but you may not be happy after achieving all your goals.

People have everything in their life, but happiness is not there.

You are spending a lot of money to be happy and people are searching for happiness everywhere in the outside world.

Do you think you will get happiness anywhere?

Can you buy happiness?


Is it possible to be happy always?


When I ask somebody are you happy? People start thinking am I happy?

The answer to all your questions is only meditation.

Meditation will change you as well as your family life.

My dear friend, meditation is the need for a new generation to live life happily and healthy.

 What is meditation?

Meditation relaxes your mind.

Meditation will rest your mind deeper than sleep.

If you meditate for 20 mins then It is equivalent to 2 hours of sleep.

How to meditate?

Meditation is very simple and easy to do.

It does not require any equipment and it is easy to learn. It can be practice anywhere. It doesn’t take much time. It only needs your 15-20 minutes. Meditation has no negative side effects. There are different kinds of meditation I will explain in my next post. I am explaining here a simple meditation technique.


  1. Sit in a silent place.
  2. Sit on bed/ chair/ yoga mat.
  3. Put alarm for some time like 10-20 mins. You start with 5 mins if you are a beginner then increase time slowly.
  4. Strengthen your spinal cord(back).
  5. Put your hands above your legs.
  6. Close your eyes.

Thousands of thoughts will be bombarding into your head, but do not open your eyes.

Let thoughts come into your mind, do not try to stop any thoughts. All thoughts will be settled down after some time.

Types Of Meditation:

Read different types of meditations.

 What are the benefits of meditations?

I. Health Benefits

1. Get more physical fitness.

2. More focus mind:

3. Normalize high blood pressure:

4. Reduce anxiety attacks

5. Decreases stress.

6. Improves mood and behavior

7. Improve the immune system

8. Increase energy levels.

9. Reduces heart diseases and stroke.

10. Improve blood circulation.

11. Less perspiration.

12. Slower respiratory rate.

13. Reduces age-related memory loss:

14. Glowing skin.

15. Reduces heart deceases:

16. Slower aging:

17. Lowers oxygen consumption

18. Decreases muscle tension

19. Reduces pre-menstrual symptoms

20. Help in chronic diseases like allergies, arthritis, etc.

21. Increases exercise tolerance.

22. Help with weight loss.

23. Reduces cholesterol level, lowers the risk of cardiovascular disease.

24. Improve the flow of air to the lungs that result in easy to breathe.

25. Help to cure headaches and migraines.

26. Reduce the need for medical care.

27. Less energy wasted.

28. Relief from asthma.

29. Improved performance in the sports activity.

30. Relaxes your nervous system.

31. Help in curing infertility

32. Improve self-confidence.

33. Resolve phobia and fear.

34. Help to control your thoughts.

35. Improve relations at home and work

36. Help to ignore small issues

37. Ability to solve a complex problem.

38. Improve will power.

39. Help to easily respond to a stressful event.

40. Decrease mental illness.

41. Improve intelligence.

42. Improve social behavior.

43. Reduces aggressiveness.

44. It requires less time to fall asleep.

45. The decrease in restless thinking.

46. Decrease the tendency to worry.

47. It helps to make a more accurate judgment.

48. Develops emotional maturity.

49. Develop a stable personality.

50. Increases listening skills.

51. Increases empathy.

52. Increases sense of responsibility.

53. Increases productivity.

54. Fewer tissue damages.

 II. Mental benefits

55. Control and reduce anxiety.

56. Reduces stress.

57. Improve emotional stability.

58. Improve self-awareness.

59. Increases happiness.

60. Develop intuition.

61. Improve sleep.

62. Help control pain.

63. Sharpen the mind.

64. Expansion of mind

65. Gain more clarity and better peace of mind.

66. Reduce depression.

67. Help to fight alcohol, nicotine, and drug addiction.

68. Improve confidence.

69. Improve focus and concentration.

70. Greater dynamism.

71. Improve creativity.

72. Increased intelligence.

73. Work efficiency.

74. Improve Personal relationships.

75. Improve Marital relationship.

76. Cure eating disorder.

77. Quitting smoking.

78. Cure autism spectrum disorder

79. Improve Decision making.

80. Improve work performance.

 III. Spiritual benefits

81. It helps to understand yourself.

82. Help to learn forgiveness.

83. Better peace of mind and happiness.

84. Improve compassion.

85. Improve harmony of mind, body, and spirit.

86. Help to live in the present moment.

IV. Benefit for Student

87. Improve Confidence

88. Improve concentration and focus.

89. Better health

90. More mentally strong.

 Now, you know all the benefits of meditation but still, some people will think why to meditate? I will explain to you why you should meditate that will open your eyes.

Why Meditation is necessary?

Medical Angle:

The heart is the most important part of our body. It works continuously from the time of our birth till death.

The heart pumps 7,000 liters of blood, out of which 70% of blood is pumped to the brain, and the remaining 30 % is pumped to the rest of our body.

Our veins are 70,000 km long and blood pumped through it.

We take rest when you are tired, but our heart never takes rest, if it will take rest then you will have to take rest for forever.

Now the question is how heart work, so efficiently and continuously.

The heart works because it follows a discipline.

The heart takes 0.3 secs to contract and 0.5 secs to relax.

Hence the heart takes 0.3+0.5=0.8 sec to complete one beat.

The normal heartbeat is 72 in 1 minute.

The impure blood travels through the lungs and becomes 100% pure during the relaxing phase of 0.5 secs.

The body demands more blood when you are stressed in less time and in this situation the heart reduces the relaxing period from 0.5 to 0.4 secs.

Thus, the heartbeats 82 times in 1 min, and only 80% of blood get purified.

When you are more stressed heart relaxing time is reduced to 0.3 secs then only 60% of blood is purified.

Thus 20-40% of impure blood which is not pumped is pumped to the veins/arteries.

These impure component gets deposited on the walls of veins and thus the elastic nature of the veins is lost. So, they become plastic in nature.

Thus, this results in a blockage that further results in a heart attack.

So, you understand that the main reason for heart problems is the increased demand for blood by the brain and the body.

25-30% of blood reaches in the brain due to diet, which you take whereas the rest 70-75% is due to thinking, emotions, memories, and another process of the brain.

So, if you want to keep your heart working effectively for a long time, you should protect yourself from worries, anger, sadness, stress, and hurry.

There is no medication is available to protect ourselves from this.

So, only the medication available is meditation.

How to get benefits from meditation?

The only way to get benefits of meditation is through regular practice.

Meditate for 20 minutes every day.

Meditation will be part of the daily routine after practicing every day.

These top 90 health, mind, and spiritual benefits of meditation will change your life.





I hope you enjoyed the top 90 health, mind, and spiritual benefits of meditation.

The whole world is going through the Covid-19 pandemic.

There is a lot of negativity everywhere in this entire world.

You need to be positive, cool, and calm in this pandemic situation.

You have to control your mind and body.

I am meditating every day.

Comment me when you are going to start meditation?

Basics of Cloud Computing



What is Cloud Computing:

Cloud computing is a technology where data is stored on the remote server on the internet.

Different operations can be done using cloud computing:

  • Store, back up or recover data on the internet.
  • Host websites or blogs.
  • Use services provided.
  • Use software provided on cloud.

Example: AWS, Azure, Google Cloud

Why Cloud Computing?

  •  Servers are required in all software companies.
  • Database server, mail servers, networking, firewalls, routers,  modem, high speed broadband internet and many maintenance engineers are required in server room.
  • Need to spend lots of money to establish and maintain the servers.
  • To overcome all these problems and IT infrastructure cost we need cloud computing.

Advantage of Cloud computing:

1. Cost Savings: Cloud computing saves cost because you don’t have to invest on physical hardware. Also no need of trained employee to maintain hardware servers. Maintenance is done by cloud service provider. You have to pay as you use the cloud services.

2. Availability: Cloud computing service providers are reliable in providing their services. These services are available 24*7. They are providing SLA of 99.9%.

3. Unlimited Storage capacity: You can choose your storage as per your business need like 2000 to 3000 GB. There is no limitations.

4. Fast Deployment: You can deploy any web sites or blog in single click.

5. Back-up and restore data: Cloud computing provider provide facility to take back and restore data automatically.

6. Easily Accessible(Mobility): Cloud computing servers and hardwares are available over internet, hence you can access servers from any where just you need internet.

7. Auto scaling: Cloud computing provides auto scaling. Hardwares like RAM, processors will be added based on user traffic for running application.

8. High speed computing power: You can select high speed hardware for your business need.

9. Low Cost Software: Cloud computing provides software to install on cloud VM. No need to buy software licenses.

10. Auto Software Updates: Software updates are handle cloud service provider and they updates software and security patches timely so no need to worried about any software updates.


Disadvantage of Cloud computing:

  •  Internet Connectivity: High speed internet is required for cloud computing. You can not access cloud without internet.
  • Downtime: There is chances that cloud computing provider can face power loss, internet connectivity or service maintenance issue.
  • Security: Company sensitive information’s are not secure on cloud as they claim to be. Some cloud hacking cases happen recently.
  • Technical Issue: Customers are dependent on cloud service providers for any kind of technical support for help. You can not fix technical problems by your self.

Types of Clouds(Deployement Models):

  • Public Cloud: Public cloud is accessible to every one. It is less secure.
  • Private Cloud: It is accessible within an organization. It is more secure because it is available inside the organization.
  • Hybrid Cloud: It combination of both public and private cloud. Some critical activities are performed using private cloud and other non-critical activity are performed using public cloud.
  • Community Cloud: It is for some group of organizations.


Cloud Services Model:

The three major Cloud Computing Offerings are:

  • Software as a Service (SaaS): This is called “On-demand software ”. You don’t have to install, setup and run the application. Service provider will do that for you. Ex: Salesforce, Dropbox, MailChimp, Microsoft Office 365
  • Platform as a Service (PaaS): You can install operating system, programming language, database and web server etc. Ex: Window Azure, Salesforce.com
  • Infrastructure as a Service (IaaS): All types of hardware’s like virtual machines, disk image library, block and file-based storage, firewalls, load balancers, IP addresses, virtual local area networks etc are provided.

Ex: Amazon EC2, Windows Azure, Rackspace, Google Compute Engine.

Why you should use C# Null Coalescing and Null Conditional Operators?

Null Coalescing operator:

Null coalescing operator is new features of C# 6.0. It uses double question mark (??). It is shorthand of “If” condition and ternary operator. It is used for null check. There are different ways to check null in C# application.

  • Null check using if else: This is traditional method to check null.
string name = Console.ReadLine();
//Null check using if else condition.
if (!string.IsNullOrEmpty(name))
Console.WriteLine("If Condition:" + name);
Console.WriteLine("Else condition: Default value");

Input: name=”Ram”;
Output: "If Condition:" Ram
Input: name=null;
Output: "Else condition: Default value"

Null check using ternary operator

//Null check using ternary operator
string value2 = name != null ? name : "Default";
Console.WriteLine("Ternary operator:" + value2);
Input: name= Ram;
Output: Ternary operator: Ram
Input: name=null;
Output: Ternary operator: Default

Null check using Null Coalescing

//Null check using Null coalescing operator
string value1 = name ?? "Default";
Console.WriteLine("Null Coalescing:" + value1);
Input: name= Ram;
Output: Null Coalescing: Ram
Input: name=null;
Output: Null Coalescing: Default
//Employee class
public class Employee
public string EmpName {get; set;}
public decimal Salary {get; set;}

//Nested Null coalescing operator
string val1 = null;
string val2 = null;
string val3 = null;
string val4 = null;

var nestedNullVal = val1??val2??val3??val4??"Undefine";

Output: Undefine

Console.WriteLine("Nested Value: " + nestedNullVal);

Employee employee = new Employee();

Null Conditional Operator ?. and ?[]

It is available in C# 6.0 and later, it is applicable to member access (?.) and element access (?[]). It checks for null value.

I. Member access: ?.

It is used for null check of entity when we access property inside it.

//Null conditional operator

var val = employee?.EmpName;

//Nested null conditional operator

var nullCond = employee?.EmpName?.Length;

Here we are accessing EmpName property of Employee Class. We are also finding length of EmpName property in next line.

II. Element access: ?[]

Null check of Array or list element can be done using element access.

List<Employee> employeeList = new List<Employee> { 
new Employee

var emp = employeeList?[0].EmpName;

Here employeeList is not null then access EmpName of first element of list.

Output: emp = Rajesh

employeeList = Null;

If employeeList is null then

Output: emp=null


  • Null Coalescing is used to check null of object.
  • Null Coalescing can be nested.
  • Null Conditional Operators is used to check null of object when we access member or element of it.  
  • Null Conditional Operators also can be nested.
  • Both reduces line of codes.

Best Front Loading washing machine under 25000 in India in June 2020


Every one need washing machine to clean all types of house hold cloths.

I was also searching for a front loading washing machine for my home.

IFB Diva Aqua SX Front Loading washing machine is best front loading washing machine under 25000 in India in 2020.

I found a fully automatic front loading washing for my home. It is really good with less price.

Diva Aqua SX 6 kg 800RPM:


Diva Aqua SX is fully automatic front loading washing machine. It is made by an Indian company IFB.

IFB washing machines are best quality washing machine in India.

IFB does not believe in advertising.  They believe in mouth to mouth promotions.

Its capacity is 6 kg.

It has warranty of 4 years warranty on product and 10 years warranty on spare parts.


Diva Aqua SX Features:

  1. Inbuilt Easy Iron: It has feature that reduces wrinkling of clothes after the final spin, making them easy to iron.
  2. Quick Wash: It has special program to help wash your clothes faster and it is good for gym clothes.
  3. Eco Wash: A special program that gives the best wash quality using optimum energy and water.
  4. Aqua Energy:   
  • It has advance magnet technology breaks calcium into minute crystal.
  • Save Energy.
  • Saves Cost.
  • Energizes water to wash better keeps cloth soft and long lasting.
  • Helps the detergent to dissolve in a precise manner so that clothes will be clean and soft.
  1. Child Lock: This feature prevents the program selection being tampered with by children.
  2. Auto Restart: Program automatically resume from the interrupted point when power supply comes.
  3. Deep Clean Technology: It acts tough on stains and makes sure cloths look fresh and new after wash.  
  4. Crescent Moon Drum: It creates a gentle water cushion that prevents damage to fabrics.             
  5. 2D Wash System: Wash and rinse cycle used shower system that ensures thorough soaking and cleaner wash. 
  6. Ball Valve Technology: Ball value lets the water out while keeping the detergent in. This technology prevents wastage and enhances the wash.
  7. Auto Balance System: It balances the clothes automatically and redistribute for stable wash.
  8. Laundry Add: Add the missed laundry.
  9. Cool Down Cycle: Hot water drained after the main wash cycle can be harmful for people and the environment. It is cooled down by taking on additional cold water automatically before draining.
  10. Start/Pause(Program Interrupt): It allow you to start and pause the program whenever you want.
  11. High-Low Voltage Protection: A smart microcontroller continuously monitors the online voltage fluctuations and temporarily stops the program to protect the machine in case the voltage drops below 150 10 V or rises above 270 10 V. The program will resume once the voltage is within safe operating range.
  12. Cradle Wash: India’s first wash program for delicate fabrics provides gentle care that uses a soft, to-and-fro, rocking movement.

Technical Specifications:

ModelDiva Aqua SX 6 kg 800RPM
Power supply220-240 V Single Phase 50 Hz
Dimension50.6cm (D) x 59.8cm (W) x 87.5cm (H)
Net weight64 kg
Capacity6 kg of dry cotton
Wash care programs8
Selector buttonsWash Mode, Rapid Wash Start/Pause, Power
Selector knobProgram Selector
Spin speed800RPM
Water consumption<= 9 Ltr/Kg/Cycle
Water pressure0.3 Bar-10 Bar (30 kPa-1000kPa)
Power consumption max2150 W
Drain pump rating30 W
Heater rating2000 W
DrumStainless Steel


Tips for best results:

  1. Before washing
    • Empty all pockets.
    • Remove metal parts from pockets.
    • Close all zips or hooks.
  2. While sorting:
    •  Separate polyester fabrics from cotton fabrics.
    • Dark clothes should be washed separately and not with whites.
    • Mix large and small clothes in each wash load.
  3. While loading:
    • Load large items first, half the total wash load.
    • Do not wash single items-add one or two similar items.
  4. Water softening:  Use water softening agents in case of hard water.



Please provide you feedback or comments. Thanks for reading.

 Please click below washing machine image to see the product on Amazon:


IFB Diva Aqua SX Front Loading washing machine is the best washing machine in India under 25000/-

 Other washing machines:

Working with Action Selectors in MVC

Action selectors are attribute in MVC. It is used with action method and in routing by routing engine to handle a request.

  1. ActionName
  2. NonAction
  3. ActionVerbs

1. ActionName:

ActionName attribute allow us to specify different action name than method name.


public ActionResult About(){

return View();


Now URL will be http://localhost:port/controler/GetData/. Action name “About” is not be consider in URLrouting.

View Name:

Now here question arises what will be name of view. View name should be GetData otherwise it will throw error. You can pass view name “About” inside view method then it will work.

Ex: View(“About”);


public ActionResult About()


return View(“About”);


2. NonAction:

All action method should be public. Sometimes we do not want method to be treated as action method and it should not be called by routing engine. We use NonAction attribute for this purpose.

public class HomeController : Controller{


public ActionResult GetData(){

return View();



3. Action Verbs(Accept Verbs):

MVC supports different kind of action verbs like HttpGet, HttpPost, HttpPut, HttpDelete,

HttpOptions and HttpPatch. These attributes are used with action method to support Http request.


  • Attribute selectors are use in URL routing by MVC routing engine.
  • ActionName attribute is used to specify different action name than method name.
  • There are three action selectors available in MVC
    • ActionName
    • NonAction
    • ActionVerbs
  • NonAction method marks the action method as public method and cannot be used by routing engine.

How For is Different from Foreach Loop in C#

This is very basic question asked in many interviews:

The for loop executes a statement or a block of statements repeatedly until a specified expression evaluates to false.

There is need to specify the loop bounds (minimum or maximum). Following is a code example of a simple for loop that starts 0 till <= 5.

int j = 0; 
for (int i = 1; i <= 5; i++) 
   j = j + i ; 

The foreach statement repeats a group of embedded statements for each element in an array or an object collection. You do not need to specify the loop bounds minimum or maximum. The following code loops through all items of an array.

int j = 0; 
int[] myArr = new int[] { 0, 1, 2, 3, 5, 8, 13 }; 
foreach (int i in myArr ) 
   j = j + i ;

foreach: Treats everything as a collection and reduces the performance. foreach creates an instance of an enumerator (returned from GetEnumerator()) and that enumerator also keeps state throughout the course of the foreach loop. It then repeatedly calls for the Next() object on the enumerator and runs your code for each object it returns.

  • Using for loop we can iterate a collection in both direction, that is from index 0 to 9 and from 9 to 0. But using for-each loop, the iteration is possible in forward direction only.
  • In variable declaration, foreach has five variable declarations (three Int32 integers and two arrays of Int32) while for has only three (two Int32 integers and one Int32 array).
  • When it goes to loop through, foreach copies the current array to a new one for the operation. While for doesn’t care of that part.

Interviewer asked me 2 scenario based question in one interview:

for (int i = 1; i <= 5; i++)  
  i = i + i;  

The above code will work?
Yes this will work.

int[] tempArr = new int[] { 0, 1, 2, 3, 5, 8, 13 };
foreach (int i in tempArr) 
   i = i + 1;

Above code will work?

This code will not compile. I have pasted screenshot of error.

Nullable Type in C#


Nullable types are introduced in C#2.0. Primitive data type like int, long cannot be assign null.

int x = null;//Compile time error


Nullable<int> i = null;

Nullable Types are instance of System.Nullable<T> struct.


public struct Nullable<T> where T : struct


public bool HasValue { get; }

public T Value { get; }


HasValue and Value Property:

Nullable types have a property called HasValue. It tells that int data type has value or not. It returns true when there is value otherwise returns false. Value property returns value of variable.


public class Program


static void Main(string[] args)


Nullable<int> x = null;

if (x.HasValue)











Value property will throw exception if value assigned is null and we are accessing the value.


How to access value of Nullable type:

GetValueOrDefault() used to get value of nullable types. It will not throw any exception if value is null. It will return default value 0 if value is null.

static void Main(string[] args)


int? i = null;




Shorthand Syntax for Nullable Types:

We can use the ? operator instead of using Nullable<T>.

Ex: int? ,Long?.

int? x = null;

long? y = null;

Type Casting:

Explicit type casting is required if type cast from nullable types to non-nullable types otherwise it will throw error.

static void Main(string[] args)


int? i = 10;

int x = (int)i;




When to Use:

Most of application uses database. Database have different types. There is no concept of value type and reference type. All data types like int, DateTime, char can hold null in database.

But how to store those null value in C# because primitive data types cannot assign null value. Nullable types allow to assign null value.


  • Nullable types can only be used with value types.
  • ? operator is shorthand syntax for nullable types.
  • Value property is used to get value of nullable types.
  • The value property will throw InvalidOperationException if value is null else it will return value.
  • The HasValue property returns true if variable contains a value or false if value is null.
  • Nested nullable types are not allowed. Nullable<Nullable<int>> i. It will give compile time error.
  • We can use == and != operators with nullable type.
  • We can also use null-coalescing operator(??) to assign value of nullable type.
  • GetValueOrDefault() method is used to get value of nullable Type. If returns 0 if value is null.
  • Nullable types are used in database programming.
  • Nullable types do not support var type. Compiler will give compiler error if used with var.
  • Explicit type casting is required to type cast from nullable types to other data type

Using Tuple in C#


Tuple<T> is class in .NET. It is data structure which can hold elements of different data types. It can be used like any entity which can hold element of different data types. We can use Tuple instead of a class with properties. It is introduced in .NET Framework 4.0.



How to Create Tuple:

There are two way to create a Tuple.

1. Create object of Tuple<T> class.

static void Main(string[] args)


Tuple<string , string , decimal> employee = new Tuple<string , string, decimal>(“E001″,”Rajesh”,10000);

Console.WriteLine(“EmpId: ” + employee.Item1);

Console.WriteLine(“Name: ” + employee.Item2);

Console.WriteLine(“Salary: ” + employee.Item3);



Here, I have created object of Tuple class which stores employee information like employee id, name and salary. I have specified the types and passed values in constructor.

2. Helper Class:

.NET Framework provide a helper class to create object of Tuple class.


static void Main(string[] args)


var employee = Tuple.Create(“E001″,”Rajesh”,10000);

Console.WriteLine(“EmpId: ” + employee.Item1);

Console.WriteLine(“Name: ” + employee.Item2);

Console.WriteLine(“Salary: ” + employee.Item3);



Here, I have not specified data types. Create method is used to create instance of Tuple class and passed

the parameters empid, name and salary. Tuple can have maximum 8 elements.

How to use Tuple:

Tuple element can be accessed with Item<ElementNumber> properties.

Ex: Item1,Item2,Item3,Item4,Item5,Item6,Item7,Item8.

Eight element is last element and it is accessed using Rest property.


static void Main(string[] args)


var employee = Tuple.Create(“E001″,”Rajesh”,”Singh”,10000,”Male”,9983632000,”Bangalore”,”R&D”);

Console.WriteLine(“EmpId: ” + employee.Item1);

Console.WriteLine(“First Name: ” + employee.Item2);

Console.WriteLine(“Last Name: ” + employee.Item3);

Console.WriteLine(“Salary: ” + employee.Item4);

Console.WriteLine(“Gender: ” + employee.Item5);

Console.WriteLine(“Mobile: ” + employee.Item6);

Console.WriteLine(“City: ” + employee.Item7);

Console.WriteLine(“Department: ” + employee.Rest);





How to use more than 8 elements in Tuple:

Sometimes there is requirement that we have to use more than 8 elements which is generally not allowed in Tuple. Max we can store 8 elements in Tuple. We have to use nested Tuple to hold more than 8 elements. We can use nested Tuple at any element. However, it is recommended to place nested tuple at the end of sequence. Last element is access by Rest property.


static void Main(string[] args)


var employee = Tuple.Create(“E001″,”Rajesh”,”Singh”,10000,”Male”,9983632000,”Bangalore”,


Console.WriteLine(“EmpId: ” + employee.Item1);

Console.WriteLine(“First Name: ” + employee.Item2);

Console.WriteLine(“Last Name: ” + employee.Item3);

Console.WriteLine(“Salary: ” + employee.Item4);

Console.WriteLine(“Gender: ” + employee.Item5);

Console.WriteLine(“Mobile: ” + employee.Item6);

Console.WriteLine(“City: ” + employee.Item7);

Console.WriteLine(“DepartmentId: ” + employee.Rest.Item1.Item1);

Console.WriteLine(“Department Name: ” + employee.Rest.Item1.Item2);





How to pass multiple parameters to Method:

We can pass multiple parameters using following:

  • Ref
  • Out
  • Class object
  • Tuple
  • Array

Tuple is one of way to pass multiple parameters to method. I will explain here about Tuple.

public class Program


static void Main(string[] args)


var employee = Tuple.Create(“E001”, “Rajesh”, 10000);




public static void GetTupleData(Tuple<string, string, int> employee)


Console.WriteLine(“EmpId: ” + employee.Item1);

Console.WriteLine(“First Name: ” + employee.Item2);

Console.WriteLine(“Salary: ” + employee.Item3);




I created instance of Tuple for employee properties holding Emp Id, Name and Salary. Passing employee object to GetTupleData() method and accessing object employee and printing on console.



How to Return multiple values from Method using Tuple:

public class Program


static void Main(string[] args)


var employee = GetTupleData();

Console.WriteLine(“EmpId: ” + employee.Item1);

Console.WriteLine(“First Name: ” + employee.Item2);

Console.WriteLine(“Last Name: ” + employee.Item3);



public static Tuple<string,string,string> GetTupleData()


return Tuple.Create(“E001”, “Rajesh”, “Singh”);



I created instance of employee which is holding EmpId, First Name and Last Name. Employee object is returned from GetTupleData() method and printing EmpId, First Name and Last Name.




  • Tuple is used to hold element of different types without creating a class.
  • Tuple is reference type.
  • Tuple can hold max 8 elements. Nested Tuple can be used to hold more than 8 elements.
  • Tuple is used to return multiple values from a method.
  • Tuple is used to pass multiple values to method.
  • Tuple elements are access using properties (Item1,Item2,Item3,Item4,Item5,Item6, Item7,Rest).

Thanks for reading.

Happy Coding. Smile

Merge in SQL Server


I attended one interview and interviewer asked me below question.

Q 1:

Id EName ECode
1 Rajesh E001
2 Suresh E002
3 Ram E003

Write a single statement to insert, update and delete operation in this table.

Q 2:

Id EName ECode
1 Rajesh E001
2 Tiger E002

Write a insert query to insert id = 2 with EName=”Tiger” and ECode=”E002” without using third variable to increment id or without using select query. You should use only inert query.

I was thinking how it is possible? Then he gave me hint about merge in SQL server. Hence I am writing this article to explain the merge concept.

What is merge statement?

Merge statement is introduced in SQL Server 2008. It is used to perform insert, update and delete in a single statement without writing multiple statement for insert, update and delete.

How to Use?

Two tables are required for merge.

  1. Source Table: Main table from where changes will be moved to target table.
  2. Target Table: The table where insert, update and delete operation will be performed.

Merge statement joins these two tables based on common column from both table.

Merge Statement Syntax:


Source Table: EmployeeSource


Target Table: EmployeeTarget


Merge statement to merge:


Merged Table:

This is final table after merge.


Points to be noted:

  • Id = 1 is present in EmployeeSource and EmployeeTarget Table. So Ename and Ecode from EmployeeSource table is updated in EmployeeTarget.
  • Id = 3 is not present in EmployeeSource table but not in EmployeeTarget table so it is deleted from EmployeeTarget table.
  • Id=2 is present in source table but not in target table so records from EmployeeSource table is inserted into EmployeeTarget Table.

Note: Answer of both question is MERGE statement as mention above.

Please provide your valuable feedback and comments.

Thanks for reading.Smile

Authentication in WebAPI

What is Authentication:

Authentication is process of determining that some one who is going to use the resources, is genuine person and has access right or in other way we can say Authentication is process to allow authorized user to access the resources of WebAPI rest service.

Why Authentication required:

WebAPI is used by broad range of applications and provide data to client application, so we have to secure WebAPI service.

Type o f Authentication:

1. Basic Authentication

2. Token based Authentication

We will learn basic Authentication in this tutorial.

Follow the below steps to implement basic authentication

Step 1: Create a Web API Project with name WebApiBasicAuthenticationDemo.

      • Got to File-> New-> Project-> ASP.NET Web Application –> Click “Next” button.
      • Enter project name WebApiBasicAuthenticationDemo then click “Create” button.
      • Select WebAPI then click “Create” button.

              Note: Visual studio 2019 is used to create WebAPI project.

Step 2:  Add a Class “Security” and method “Login” to authenticate user. Login method will take user name and password as parameter and it is authenticate in DB. Here username = “raj” and password = “singh”. You can verify username and password from DB using ADO.NET or entity framework.


Step 3: Add BasicAuthentication class with below code.


Here BasicAuthenticationAttribute is inheriting AuthorizationFilterAttribute and overriding OnAuthorization method. BasicAuthentication is returning username and password. This username and password  is used to verify  the  user by Login method. It will  return unauthorized,  if BasicAuthentication is not set or authentication fails.

Step 4: Add BasicAuthentication Attribute above Controller as shown below.


Here I am setting [BasicAuthentication] attribute to Controller label. OnAuthorization() will be called when ever any WebAPI Get/Post/Put/Delete method is called. You can set this attribute at method label also but authentication will be done for method only, not for all methods.

Step 5: Select Authorization tab in post man.

  • Select Authorization type as Basic Auth.
  • Enter user name and password as shown in below screenshot


Here Get method without parameter will be called and it will return array of strings as shown in above screenshot.

Thanks for reading.clip_image001

Share via
Copy link
Powered by Social Snap