using static System.Console;
using System.Collections.Generic;
public class Program {
public static void Main() => WriteLine(ToQueryString(new { nome = "Nome", valor = 10 }));
public static string ToQueryString<T>(T model) {
var query = new Dictionary<string, string>();
foreach (var property in typeof(T).GetProperties())
query.Add(property.Name, property.GetValue(model, null).ToString());
return string.Join("&", query);
}
}
//https://pt.stackoverflow.com/q/252611/101
dXNpbmcgc3RhdGljIFN5c3RlbS5Db25zb2xlOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKCQkJCQkKcHVibGljIGNsYXNzIFByb2dyYW0gewoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKSA9PiBXcml0ZUxpbmUoVG9RdWVyeVN0cmluZyhuZXcgeyBub21lID0gIk5vbWUiLCB2YWxvciA9IDEwIH0pKTsKCglwdWJsaWMgc3RhdGljIHN0cmluZyBUb1F1ZXJ5U3RyaW5nPFQ+KFQgbW9kZWwpIHsKCQl2YXIgcXVlcnkgPSBuZXcgRGljdGlvbmFyeTxzdHJpbmcsIHN0cmluZz4oKTsKCQlmb3JlYWNoICh2YXIgcHJvcGVydHkgaW4gdHlwZW9mKFQpLkdldFByb3BlcnRpZXMoKSkKCQkJcXVlcnkuQWRkKHByb3BlcnR5Lk5hbWUsIHByb3BlcnR5LkdldFZhbHVlKG1vZGVsLCBudWxsKS5Ub1N0cmluZygpKTsKCQlyZXR1cm4gc3RyaW5nLkpvaW4oIiYiLCBxdWVyeSk7Cgl9Cn0KCi8vaHR0cHM6Ly9wdC5zdGFja292ZXJmbG93LmNvbS9xLzI1MjYxMS8xMDE=