Having this data:
class User
{
public string Name {get; set;}
public string SurrName {get; set;}
}
class Book
{
public int Id {get; set;}
public string Title {get; set;}
}
var user = getSampleUser();
var book = getSampleBook();
I want to create string which will constains serialized object to &name=value
.
var userContent = user.ToRequestContent(); // "&Name=Adam&Surrname=Smith";
var bookContent = book.ToRequestContent(); // "&Id=5&Title=7";
How can I do that?