I use classes to respond to PageMethods in some webpages. Asp.net engine automatically serializes the Class to JSON. I have few classes that have common properties like "RequestState"-Enum and "Error"-String which represent the State of the Request and the String describing the Error if any. For example look into this class below,
public class Contacts
{
public string Name { get; set; }
public string Country { get; set; }
public RequestState RequestState { get; set; }
public string Message { get; set; }
}
last two properties come in more than 4-5 classes. How do i abstract these properties so that they become common instead of declaring them in each class like how i do now. Interface could be possible i would like your ideas too for this, code snippet would be highly appreciated. thanks 🙂
1 Answer