How can I implement an “optional” parameter for a function, so when endMarker not set, will I use the value from the required startMarker parameter? I am currently using a type with a null value and checking if endMarker null, I set it to startMarker
protected void wrapText(string startMarker, string? endMarker = null) { if (endMarker == null) endMarker = startMarker; }
but now the problem is that I get the error message: can it not use string? in string
(string)endMarker
how can i use endMarker for string so i can use it? or is there a better way to implement this?
source share