public ResponseResult GetData(int id) { try { var data = _dataService.GetData(id); return ResponseResult.Success(data); } catch(Exception ex) { return ResponseResult.Error(ex.Message); } }
public ResponseResult SaveData(DataObject dataObject) { try { _dataService.SaveData(dataObject); return ResponseResult.Success(); } catch(Exception ex) { return ResponseResult.Error(ex.Message); } }In the above example, the SaveData method tries to save data using the provided DataObject. If the operation is successful, it returns a ResponseResult Success object. If an error occurs, it returns a ResponseResult Error object with the error message. In conclusion, ResponseResult Success is a widely used response object in C# applications that provides a standardized way of encapsulating response data. The Newtonsoft.Json package is just one of the many libraries that support ResponseResult Success in C#.