How do we customize Data Contract Names for Generics types?

 Posted by Sgandikota on 7/14/2011 | Category: WCF Interview questions | Views: 5032 | Points: 40

We can customize the generic datacontract names by allowing parameters. Find the Example below

[DataContract(Name = "Shape_{1}_brush_and_{0}_shape")]
public class Shape< Square,RedBrush>
// Code not shown.

Here, the Data Contract Name is "Shape_RedBrush_brush_and_Square_shape”
{0} – First Parameter in the generic type.
{1}- Second Parameter in the generic type.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response