[Codewars #56] Remove First and Last Character (8kyu)

[Codewars #56] Remove First and Last Character (8kyu) 문제 풀이

Posted by karais89 on January 26, 2019

Instructions

링크

It’s pretty straightforward. Your goal is to create a function that removes the first and last characters of a string. You’re given one parameter, the original string. You don’t have to worry with strings with less than two characters.

My Solution

1
2
3
4
5
6
7
8
9
10
using System;

        public class Kata
        {
            public static string Remove_char(string s)
            {
                // Your Code
                return s.Substring(1, s.Length - 2);
            }
        }
  • c# Substring 메서드를 사용하면 쉽게 해결 가능

Best Practices

1
2
3
4
5
6
7
8
9
using System;

        public class Kata
        {
            public static string Remove_char(string s)
            {
                return s.Substring(1,(s.Length - 2));
            }
        }
  • 똑같은 방식으로 해결