Forum

Class'da aldığım ha...
 
Bildirimler
Hepsini Temizle

Class'da aldığım hata: Error 45 Extension method must be defined in a non-generic static class

2 Yazılar
2 Üyeler
0 Likes
1,427 Görüntüleme
(@HuseyinTopcu)
Gönderiler: 111
Estimable Member
Konu başlatıcı
 

Merhaba arkadaşlar aşağıdaki gibi bir class'ı class dosyasının içinde yazınca aşağıdaki gibi hata alıyorum. Bu class'ı nasıl kullanabilirim?

Aldığım hata: Error 45 Extension method must be defined in a non-generic static class 

public static string ToURL(this string s)

        {

            if (string.IsNullOrEmpty(s)) return "";

            if (s.Length > 80)

                s = s.Substring(0, 80);

            s = s.Replace("ş", "s");

            s = s.Replace("Ş", "S");

            s = s.Replace("ğ", "g");

            s = s.Replace("Ğ", "G");

            s = s.Replace("İ", "I");

            s = s.Replace("ı", "i");

            s = s.Replace("ç", "c");

            s = s.Replace("Ç", "C");

            s = s.Replace("ö", "o");

            s = s.Replace("Ö", "O");

            s = s.Replace("ü", "u");

            s = s.Replace("Ü", "U");

            s = s.Replace("'", "");

            s = s.Replace("\"", "");

            Regex r = new Regex("[^a-zA-Z0-9_-]");

            s = r.Replace(s, "-");

            if (!string.IsNullOrEmpty(s))

                while (s.IndexOf("--") > -1)

                    s = s.Replace("--", "-");

            if (s.StartsWith("-")) s = s.Substring(1);

            if (s.EndsWith("-")) s = s.Substring(0, s.Length - 1);

            return s;

        } 

 

 
Gönderildi : 23/01/2015 20:55

(@eravse)
Gönderiler: 1753
Üye
 

muhtemelen public bir class icinde bu methodu kullaniyorsunuz bunu baska bir class icine alin public static class abc gibi daha sonra deger.ToUrl gibi kullanin 

ProfectSoft Yazılım ve Danışmanlık Hizmetleri
LogPusher & Bifyou E-Commerce System
www.profectsoft.com

 
Gönderildi : 24/01/2015 13:40

Paylaş: