Stille Tage fordern uns, die Wirklichkeit neu zu hinterfragen
Anzeige
Yes – the logic can stay the same, you just need to write it so that it works with either type.
In practice that means either:
* **Make the method generic** – let the compiler infer the type (`T`) and use it for the variable, or
* **Overload the method** – write two versions, one that takes a `string` and one that takes a `char`.
The body of the method will be identical; only the type of the variable changes. So you can keep the same code for both cases, just adjust the type declaration.