[Resolved] String cannot be of zero length. Parameter name: oldValue
I have the code below when I replace variable text0 with text1. I got an error String cannot be of zero length. Parameter name: oldValue.
string text0 = string.Empty; string text1 = "This is text 1"; string text2 = text1.Replace(text0, ""); Console.WriteLine(text2);
I don't know what is oldValue param? and How can I fix this issue?
Marry Christ Sep 26 2020
In c#/ Asp.net Core,
Replace()method accepts two parameters as below:
public String Replace(String oldValue, String? newValue);
oldValueparameter is required and not accept value null or empty. In your example
text0variable is empty so it throws that exception. Please sure that
text0must NOT null or empty.