Just like the title says.
I\'ve tried doing str.Replace(\"\",\"0\");
but it gave me error because oldValue
has zero length.
Is it possi
You can't replace empty string within the string, but you can replace, say, spaces, e.g.
str = str.Replace(" ", "0"); // providing str is not null
Or you can substitute empty string with "0"
:
if (String.IsNullOrEmpty(str))
str = "0";
When parsing string
into int
you can do something like that:
int x = String.IsNullOrEmpty(str) ? 0 : Convert.ToInt32(str);