You can change the base
address, binding and contract if you are not aware about these then not a
problem you can visit this article - WCF
IService1.cs - This contains
and Service Contract and Data Contract. You can change it anytime. IService1 is
the contract of your service so name of this interface and in the app.config
file should be same.
Now we are done with the
service rebuild the project and click on the run button. This will host the
service. Visual studio will take care of this. When you run this service a WCF
test client will be launched. Like below -
If you do not see your service projects it means that there
is some problem with your port. IF you are getting below error -
Hello Everyone, In this article we will talk about Func< in T, out TResult>Delegate.
It is another readymade delegate that provides
by .Net framework. It can encapsulate a method that takes some parameters as
input and returns an output as TResult.
So in general Func is a delegate
1. Which takes from 0 to 16 parameters.
2.It is contra variant
and co variant both. Input parameters are contra variant and Output parameters
are co variant.
Where can we use Func delegate ?
You can use this delegate to encapsulate a method where you
need to pass some parameter( 0 to 16 ) and need to get some result. In this
case you do not need to explicitly create a delegate. Func is perfect
Let's see a complete example of Func delegate -
Use case - Let's say An array is given and you have
to print only odd numbers.
Solution - You can create a foreach loop and
checkif the number is odd then print
At later stage of development you get some more rules added.
Let's say print those odd numbers which are greater than 5.
So in this case you have to modify your for loop which can
be at the UI level. In that case we will break some SOLID rules.
the solution ?
We can create a Func that takes input of array and apply all
the rules and return list of data or one by one. This can be at model level and
UI won't be aware of the logic and functionality.
Hope you like reading the article. Please inbox me in case
of any confusion.
Hello everyone, in this article we will talk about “Action” a readymade delegate. Action is just another delegate that takes some parameters and doesn’t return a value. So when do you want to execute some method which doesn’t return any value then rather creating your own delegate. .Net framework provides us an Action Delegate. Please have a look on below image –
So In general Action is a delegate -
Which is contra variant ( in parameterwill discuss this in next articles )
Which takes 1 to 16 parameters but do not return any value.
So let’s take an example of using Action –
Action obj = new Action(MyDummyMethod);
// You can call it as asynchronous way because this is just a delegate
Cool J So we saw in this example we can invoke an action as a synchronous way as well as asynchronous way because Action is none other than a delegate.
This is my personal blog and i write articles on .Net, WPF, C#, OOPS, Threading and other .Net technologies. This is not related to any of my employer and organizations. This is the result of my personal interest.