먼저 문자열을 설정하십시오 -
string str = "Football and Tennis";
이제 substring() 메서드를 사용하여 마지막 4개 문자를 가져옵니다. -
str.Substring(str.Length - 4);
전체 코드를 보자 -
예시
using System;
public class Demo {
public static void Main() {
string str = "Football and Tennis";
string res = str.Substring(str.Length - 4);
Console.WriteLine(res);
}
} 출력
nnis