1.

How Do We Customize Data Contract Names For Generics Types?

Answer»

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.

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.



Discussion

No Comment Found