public static class ApiHelper { public static ReslultInfoTry (Action > action) { var r = new ReslultInfo (); try { action(r); } catch (Exception ex) { r.code = ReslultCode.error; r.desc = ex.Message; } return r; } } public enum ReslultCode { sucess, error } public class ReslultInfo { public ReslultInfo() { code = ReslultCode.sucess; desc = ""; } //result:sucess/error public ReslultCode code { get; set; } public string desc { get; set; } public T Data { get; set; } }