Can someone explain what the code does step by step?
I don't understand, what does the .replace do and (" ", string.Empty)?
And what seems to be the purpose of it?
5 Replies
❯ Method: System.String.Replace(Char, Char)
Returns a new string in which all occurrences of a specified Unicode character in this instance are replaced with another specified Unicode character.
❯ Method: System.String.Replace(String, String)
Returns a new string in which all occurrences of a specified string in the current instance are replaced with another specified string.
❯ Method: System.String.Replace(String, String, Boolean, CultureInfo)
Returns a new string in which all occurrences of a specified string in the current instance are replaced with another specified string, using the provided culture and case sensitivity.
3/6 results shown ~ Click Here for more results
React with ❌ to remove this embed.
thinker227#5176
REPL Result: Success
Console Output
Compile: 649.401ms | Execution: 85.147ms | React with ❌ to remove this embed.
It essentially just does a search-and-replace on the string it's called on. The first argument is the string to search for, the second argument is the string to replace matches with.
This code just replaces all spaces in the string with an empty string, i.e. just removing all spaces.
oh ok thanks, how do i call on the second method and is there a specific meaning to "orig"?
public CompactString(CompactString orig)
{
this.saveString = orig.saveString;
}
orig
is just the parameter name
That method is a constructor
It's called by new