"Input string was not in a correct format."
See original GitHub issueHi, I have been using your Outcomes for a while and it helps me a lot until today I have a weird error. I have a function return IOutcom<int> as following:
public IOutcome<int> CreateResource(string type, string json, string id)
{
...
IOutcome<IList<ValidationError>> validation = ValidateResource(rType,json);
if (validation.Failure)
{
string message = "Resource is invalid: " + JsonConvert.SerializeObject(validation.Value);
return Outcomes.Failure<int>().WithMessage(message);
}
...
}
the “return” line keeps raise an exception “Input string was not in a correct format.”, I have tried WithMessage(“message”), it had the same error, but WithMessage(“1”) has no problem. It looks it trying to cast the string in WithMessage to int, why?
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
c# - Input string was not in a correct format
The error means that the string you're trying to parse an integer from doesn't actually contain a valid integer.
Read more >How to resolve "Input string was not in the correct format" ...
An attempt to reload this user information into the screen, produces the "Input not in the correct format" error just because the prepopulated ......
Read more >Input String Was Not in a Correct Format: Working Solutions
Input string was not in a correct format error occurs when you convert non-numeric data into an int or exceed the limit of...
Read more >System.FormatException: 'Input string was not in a correct ...
When dealing with a TextBox that should be an int do not allow invalid entries e.g. disallow non in values then use intTryParse...
Read more >[Solved] C# system.formatexception: 'input string was not in ...
I am getting error c# system.FormatException: 'Input string was not in a correct format.' for the below code. I have tried several threads...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What if check the paramList first ? At least it won’t cause trouble if my intention is a simple string message.
public SuccessOutcomeBuilder<TValue> WithMessage(string message, params object[] paramList) { if ( paramList !=null && paramList.Length >0) { message = string.Format(message, paramList); } base.Messages.Add(message); return this; }
I have created a pull request. This is my first time use Github “pull request”, please let me know if I have done something wrong.