Created
February 1, 2020 20:48
-
-
Save panther99/d40ad61d9fb1d9d3dc9ee202d6f41f92 to your computer and use it in GitHub Desktop.
String peeler challenge solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class StringPeeler | |
{ | |
public static string RemoveFirstAndLastLetter(string text) | |
{ | |
string trimmedText = text.Trim(); | |
return trimmedText.Length < 3 | |
? null | |
: trimmedText.Substring(1, trimmedText.Length - 2); | |
} | |
public static void Main() | |
{ | |
string sentence = "I am just playing my best move"; | |
Console.WriteLine(Program.RemoveFirstAndLastLetter(sentence)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment