सबसे पहले, स्ट्रिंग सेट करें -
string str = "Football and Tennis";
अब, अंतिम 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