Timeline for How would I design a TryParse method which provides detailed information in case of a parsing error?
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 20, 2019 at 20:08 | comment | added | GHP | I like this answer very much, but would not have a problem if there was a static method on Foo called "Parse(string fooString)" which returned a ParseResult<Foo>. | |
| Jan 22, 2018 at 15:51 | history | edited | TheCatWhisperer | CC BY-SA 3.0 | added 108 characters in body |
| Jan 22, 2018 at 15:50 | comment | added | Robert Harvey | @JacquesB: I was kinda wondering the same thing. The method signature is compatible with modanic behavior, but that's about it. | |
| Jan 22, 2018 at 15:49 | comment | added | Robert Harvey | @Heinzi: Any method that returns a Func<T> would meet that criteria, if you include in T the information you need. Returning detailed error information is largely up to you. Have you considered using a Maybe<T>? See mikhail.io/2016/01/monads-explained-in-csharp | |
| Jan 22, 2018 at 15:49 | comment | added | JacquesB | How is that a monad? | |
| Jan 22, 2018 at 15:46 | comment | added | Heinzi | And, w.r.t. my bolded question, can you give me an example from the .NET BCL that uses this pattern? | |
| Jan 22, 2018 at 15:41 | comment | added | Heinzi | I understand your comment about UI layer binding, but in this case there exists a standardized, canonical string representation of Foo, so it makes sense to have Foo.ToString and Foo.Parse. | |
| Jan 22, 2018 at 15:38 | history | answered | TheCatWhisperer | CC BY-SA 3.0 |