c# - Is there a subtle error in this type? -
found in our codebase , took while figure out (and had use debugger). class 1 thing not quite intended.
thought i'd share!
edit got rid of syntax error, sorry!
public class recordnotfoundexception : applicationexception { readonly string _entityname; public string entityname { { return _entityname; } } readonly string _details; public override string message { { return string.format("can't find record {0}.", _entityname) + _details != null ? string.format(" details: {0}", _details) : ""; } } public recordnotfoundexception(string entityname) { _entityname = entityname; } public recordnotfoundexception(string entityname, string details) : this(entityname) { _details = details; } }
although question vague, problem, change message
property this:
public override string message { { return string.format("can't find record {0}.", _entityname) + _details != null ? string.format(" details: {0}", _details): string.empty; } }
Comments
Post a Comment