Actual need "Subash Dash"
Loading
Actual need "Subash Dash"
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Tuhin PaulPosted Jun 8, 2023, 8:44 AM
Supporting to @Amit's code snippet submission:
Input String:
string input = "DESKTOP-CK9M9CB\\Subash Dash";
A string variable named `input` is declared and assigned the value `"DESKTOP-CK9M9CB\\Subash Dash"`. It represents a computer name followed by a backslash (`\`) and a user name.
Output String:
string output = input.Substring(input.IndexOf('\\') + 1);
A new string variable named `output` is declared. The `Substring` method is used to extract a portion of the `input` string starting from the character after the backslash (`\`).
The `IndexOf` method is used to find the position of the first occurrence of the backslash (`\`) within the `input` string. The `+ 1` is added to start the substring from the next character after the backslash. This is because `IndexOf` returns the zero-based index, and adding 1 moves the starting point of the substring to the character after the backslash.
Amit MohantyPosted May 31, 2023, 1:10 PM
Check this: