Skip to content

Instantly share code, notes, and snippets.

@jbollman7
Created January 3, 2022 22:18
Show Gist options
  • Save jbollman7/b3cb5ffd72e15f2070418c8e6931aea9 to your computer and use it in GitHub Desktop.
Save jbollman7/b3cb5ffd72e15f2070418c8e6931aea9 to your computer and use it in GitHub Desktop.
Split Join JS to C# equivalent.
console.log(readline().split(' ').reverse().join(' ')); //JS taking string input, splitting on whitespace, reversing the order of the string array, and joining the array back to a single string.
//Below is the c# equivalent
var t = input.Split(' ').Reverse();
var reversedstring = String.Join(' ', t); //Join is a static method, so I cannot chain like JS.
Console.WriteLine(reversedstring);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment