What is the attribute in the C#.NET code?

Posted by Kinliverpool under C# on 12/19/2012 | Points: 10 | Views : 771 | Status : [Member] | Replies : 3
Say for example below,

using System.ServiceModel;

[ServiceContract]
public interface ICalculator
{
[OperationContract]
// It would be equivalent to write explicitly:
// [OperationContract(IsOneWay=false)]
int Add(int a, int b);

[OperationContract]
int Subtract(int a, int b);

int Multiply(int a, int b)
}

I do not know what the attributes means and uses for like [ServiceContract] or [OperationContract].

Thank you for replying.

Kin Liverpool


Responses

Posted by: Pavanandey on: 12/20/2012 [Member] Bronze | Points: 25

Up
0
Down
They are used such that they have there identity

Thanks
Pavan Kumar
Mark Answer if this fits the need

Kinliverpool, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Subramanyame on: 12/27/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

These attribute are used to expose the service and as well as methods in the service to client.
See the attachment sample according to your example,
int Multiply(int a, int b) doesn't have a operation contract so it will not exposed to client.
 Download source file

Kinliverpool, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kinliverpool on: 12/27/2012 [Member] Starter | Points: 25

Up
0
Down
oh Thanks

Kin Liverpool

Kinliverpool, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response