非泛型静态类给我的Seo错误扩展方法错误

本文关键字:错误 扩展 方法 Seo 我的 泛型 静态类 | 更新日期: 2023-09-27 18:01:57

我得到错误:错误扩展方法必须在非泛型静态类中定义如何解决这个问题?我试着把public static,但它不起作用?

public partial class seo : System.Web.UI.Page   
{
  protected void Page_Load(object sender, EventArgs e)
    {
        List<TurBilgileri> lst = DbSorgular.KisiBilgileriBind();
        foreach (TurBilgileri item in lst)
        {
            int IDM = item.ID;
            string TurAdM = item.TurAd.ToString();
            string TurSeoM = item.TurAd.ToString();
            Response.Write(IDM + "<br>");
            Response.Write(TurAdM + "<br>");
            Response.Write(TurSeoM + "<br>");  
        }
    }
        public class TurBilgileri
        {
            public int ID { get; set; }
            public string TurAd { get; set; }
            public string TurSeo { get; set; }
        }
        public class DbSorgular
        {
            public static List<TurBilgileri> KisiBilgileriBind()
            {
                DBt system = new DBt();

                DataTable dt = system.GetDataTable("Select * from tur");
                List<TurBilgileri> lst = new List<TurBilgileri>();

                foreach (DataRow dr in dt.Rows)
                {
                    lst.Add(new TurBilgileri()
                    {
                        ID = Convert.ToInt32(dr["ID"].ToString()),
                        TurAd = dr["TurAd"].ToString(),
                        **TurSeo = UrlseoTP3(dr["TurAd"].ToString()),**

                    });
                }
                return lst;
            }
        }
        public static string UrlseoTP3(this string kelime)
        {
            if (kelime == "" || kelime.Length == 1)
                return "";
            kelime = kelime.TrimStart();
            kelime = kelime.TrimEnd();
            kelime = kelime.Replace("'"", "");
            kelime = kelime.Replace("*", "-");
            kelime = kelime.Replace("ı", ");
            kelime = kelime.Replace("!", "");
            kelime = kelime.Replace("'", "");
            kelime = kelime.Replace(":", "-");
            kelime = kelime.Replace("=", "-");
            kelime = kelime.Replace(".", "-");
            kelime = kelime.Replace(";", "-");
            kelime = kelime.Replace("%", "-");
            kelime = kelime.Replace("(", "-");
            kelime = kelime.Replace(")", "-");
            kelime = kelime.Replace("[", "-");
            kelime = kelime.Replace("]", "");
            kelime = kelime.Replace(" ", "-");
            kelime = kelime.Replace("_", "-");
            kelime = kelime.Replace("---", "-");
            kelime = kelime.Replace("--", "-");
            kelime = kelime.ToLower();
            return kelime;
        }
    }

非泛型静态类给我的Seo错误扩展方法错误

听错误信息。将扩展方法UrlseoTP3放入非泛型staticpublic类中。

public static class Extensions 
{
     public static string UrlseoTP3(this string kelime)
     {
        ...
     }
}