Monday, 23 October 2017
Named Parameters in C#.
in: asp csharp
In this article we will discuss about How to use Named Parameters in C#.
By using Named Parameters in C#, We can Pass Value to Parameter in any Sequency or Order without worrying about any data.
For Example:-
------------------------
First let me take an example without Using Named Parameters and later on i will tell you the problem and How to resolve it.
Let's take an method,
private void NamedParamEx(string Fname,string Lname)
{
// Our rest Of Code
}
while calling this method we need to pass 2 Parameters as Fname and Lname which is as below,
NamedParamEx("James","Wrink");
the above Calling looks good but what if we Swaps the 2 values then everthing goes Wrong.
To OverCome that Problem, Named Parameters Came into picture and example is as below,
NamedParamEx(Fname:"James",Lname:"Wrink");
or
NamedParamEx(Lname:"Wrink",Fname:"James");
The above 2 example works fine in both the Scenarios and it is better to Use Named Parameters because to avoid misplacing of data.
RELATED POSTS

HTTP Error 500.22 - Internal Server Error (An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.)
The issue is caused by the pipeline mode in your Application Pool setting ...

Null-Conditional Operator in C# 6.0
Null-Conditional Operator is a new Concept in C# 6.0 that is useful when ...

Difference between First() and FirstOrDefault() in C#.
In this article, We will discuss about What is the difference between Fi ...

Diffenence Between string str=""; and string str1=string.Empty; in C#.
Whenever we declare string str=""; then it will create a new object. But ...
-
This issue is Completely related to EntityFramework and this issue arises whenever you have installed EntityFramework in one project at th...
-
This is generally a Common Problem or the error could be like this, To Resolve this error, One Small Solution is Exists which is as b...
-
In this article, We will discuss What is the above Error and How to resolve this Error. Whenever, We are Restoring our database into A...
0 comments:
Post a Comment