Is there any way to do this below? Imagine a general result wrapper class. Where do you have the type and its associated error list. When the result is not returned to the user, we will use a boolean to indicate failure success. I want to create a constructor that accepts a list of errors, and if the list is null or count 0 and the type is bool / Boolean, I want to set it to true ....
It seems simple but surprisingly impossible.
public class Result<T>{ private T valueObject { get;set;} private List<Error> errors{ get;set;} public Result(T valueObj, List<Error> errorList){ this.valueObject = valueObj; this.errors = errorList; } public Result(List<Error> errors) { this.valueObject = default(ReturnType); if (valueObject is Boolean) {
}
Am I missing something simple? In general, I would prefer to do this without thinking.
source share