1. C# / Говнокод #2505

    +144.9

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    public class YobaButton : Button
    {
        public YobaButton ()
        {
            this.Click += (s1, e1) =>
            {
                MessageBox.Show ("Оп хуй.");
     
                this.Click -= (EventHandler)Delegate.CreateDelegate (typeof (EventHandler), this, (MethodInfo)MethodBase.GetCurrentMethod ());
     
                this.Click += (s2, e2) =>
                {
                    MessageBox.Show ("Оп тупой хуй.");
                };
            };
        }
    }

    Yurik, 30 Января 2010

    Комментарии (22)
  2. C# / Говнокод #2501

    +135.9

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    public class PlayerWindow
    {
        private readonly ScheduleManager _scheduleManager = new ScheduleManager();
    
    ...
    
        private void OpenSchedule(string timesheetFilename)
        {
            if (!_scheduleManager.OpenSchedule(timesheetFilename))
            {
                _isOpen = false;
                return;
            }
    
            _isOpen = false;
        }
    }

    Собственное творчество. ^_^

    spbAngel, 29 Января 2010

    Комментарии (9)
  3. C# / Говнокод #2495

    +144.5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    bool condition = item.AccessPermissionId.HasValue ? true : false;
       if (condition)
       {
          ...
       }

    зачем ?!

    the_boris30, 28 Января 2010

    Комментарии (10)
  4. C# / Говнокод #2474

    +138.9

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    public static class Test3
            {
                public delegate object MyDelegate(object o);
                public delegate T MyDelegate<T>(T o);
    
                public static void Run()
                {
                    MyDelegate dlgA = (o) => { return o; };
                    
                    MyDelegate<object> dlgB = (i) => { return i; };
    
                    MyDelegate dlg = ChangeType<MyDelegate>(dlgB);
                }
                static T ChangeType<T>(Delegate dlg)
                {
                    return (T)(object)Delegate.CreateDelegate(typeof(T), dlg.Target, dlg.Method);
                }
            }

    Люблю вкусняшку))

    fekrado, 22 Января 2010

    Комментарии (16)
  5. C# / Говнокод #2458

    +137.7

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    if (e.Source.GetType().Name.ToString()=="Square")
                        {
                            if (((Square)e.Source).Background == SystemColors.ControlBrush)
                            {
                                if ((((Square)e.Source).Content.Equals("")))
                                {
                                    ((Square)e.Source).Background = Brushes.Blue;
                                }
                            }
                            else
                            {
                                if (((Square)e.Source).Background != Brushes.White)
                                    if (((Square)e.Source).Background != Brushes.Red)
                                        if (((Square)e.Source).Background != Brushes.Green)
                                        ((Square)e.Source).Background = SystemColors.ControlBrush;
                            }
                        }

    poacher, 20 Января 2010

    Комментарии (4)
  6. C# / Говнокод #2447

    +112.2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if (ctrl.GetType().Name == "TextBox")
    {
           TextBox tb = (TextBox)ctrl;
    
         // остальное вырезано
    }

    Я даже комментить не могу это.

    headliner, 19 Января 2010

    Комментарии (8)
  7. C# / Говнокод #2414

    +144.2

    1. 1
    if ( strlen(f.ToString()) < 5 )

    Проверку булевской переменной.

    Говногость, 14 Января 2010

    Комментарии (9)
  8. C# / Говнокод #2407

    +99.4

    1. 1
    2. 2
    3. 3
    4. 4
    string date_format = DateTime.Now.ToString("dddd dd") + "th " + DateTime.Now.ToString("MMMM yyyy");
    if (DateTime.Now.Day == 1 || DateTime.Now.Day == 21 || DateTime.Now.Day == 31) date_format = DateTime.Now.ToString("dddd dd")+"st "+DateTime.Now.ToString("MMMM yyyy");
    else if (DateTime.Now.Day == 2 || DateTime.Now.Day == 22) date_format = DateTime.Now.ToString("dddd dd")+"nd "+DateTime.Now.ToString("MMMM yyyy");
                else if (DateTime.Now.Day == 3 || DateTime.Now.Day == 23) date_format = DateTime.Now.ToString("dddd dd")+"rd "+DateTime.Now.ToString("MMMM yyyy");

    DateTime formatting - don't try this at home!

    bugotrep, 14 Января 2010

    Комментарии (5)
  9. C# / Говнокод #2383

    +92.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    name[0].InnerText = Regex.Replace(name[0].InnerText, @"<[^>]+>", string.Empty);
    name[0].InnerText = Regex.Replace(name[0].InnerText, "a*[a-z]*A*[A-Z]*", string.Empty);
    name[0].InnerText = Regex.Replace(name[0].InnerText, ",", string.Empty);
    name[0].InnerText = Regex.Replace(name[0].InnerText, "\\.", string.Empty);
    name[0].InnerText = Regex.Replace(name[0].InnerText, ";", string.Empty);
    name[0].InnerText = Regex.Replace(name[0].InnerText, "&", string.Empty);
    name[0].InnerText = Regex.Replace(name[0].InnerText, "\\?", string.Empty); 
    name[0].InnerText = Regex.Replace(name[0].InnerText, "\n", string.Empty);
    name[0].InnerText = Regex.Replace(name[0].InnerText, " ", string.Empty);

    такие дела. кстати, как улучшить? :)) Нужно, чтобы обрезалось все, кроме чисел (положительных и отрицательных) Я какбе начинающий

    Yurik, 07 Января 2010

    Комментарии (21)
  10. C# / Говнокод #2370

    +943.7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    static string ConCat(string str0,string str1)
            {
                if (str0 is string && str1 is string) return str0 + str1;
                else return null;
            }

    А вдруг НЕ строку подсунут....

    psina-from-ua, 04 Января 2010

    Комментарии (8)