Created
February 1, 2020 20:48
String peeler challenge solution
This file contains 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