Error message: Input string was not in a correct format Error when i try to use String.Format in C#.
below are the code that have problem
info = string.Format("{\"name\":\"{0}\",\"img\":\"{1}\",\"href\":\"{2}\"}", Username, PhotoUrl, UserId);
try to figure out here and there and finally found the problem and solution. It's caused by both { and }.
To solve this problem, change { to {{ and } to }}. It will become
info = string.Format("{{\"name\":\"{0}\",\"img\":\"{1}\",\"href\":\"{2}\"}}", Username, PhotoUrl, UserId);
problem solved!
3 comments:
hi
var queryString = string.Format("filename={0}&filestream={1}&append={2)", fileName, Convert.ToBase64String(b, 0, bytesRead).ToString(), 1);
above line of code giving error 'Input string was not in a correct format.' can any one help me why this is happening .
hi
var queryString = string.Format("filename={0}&filestream={1}&append={2)", fileName, Convert.ToBase64String(b, 0, bytesRead).ToString(), 1);
above line of code giving error 'Input string was not in a correct format.' can any one help me why this is happening .
You are using a ')' instead of a '}' for the closing brace of your 3 parameter (#2). i.e., you have "{2)" instead of "{2}".
Post a Comment