DEV Community

loading...

Discussion on: Daily Challenge #1 - String Peeler

Collapse
viniciuscavagnolli profile image
Vinicius Cavagnolli

VB5 / VB6

Function Challenge1(input As String) As String
    If len(input) <= 2 Then
        Challenge1 = Nothing
    Else
        Challenge1 = Mid$(input, 2, len(input) - 2) 
    End If
End Function

Visual Basic .NET

Function Challenge1(input as String)
    Return If(input.Length > 2, Mid(input, 2, len(input) - 2), Nothing)
End Function

C#

string Challenge1(string input) => input.Length > 2 ? input.Substring(1, input.Length - 2) : null;

C# using LINQ (because yes)

string Challenge1(string input) => input.Length > 2 ? string.Concat(input.Skip(1).Take(input.Length - 2)) : null;