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

    +958

    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
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    namespace sortFiles
    {
        public partial class Form1 : Form
        {
            private void listBox1_DragDrop(object sender, DragEventArgs e)
            {
                this.listBox1.Items.AddRange((string[])e.Data.GetData(DataFormats.FileDrop, false));
            }
    
            private void listBox1_DragEnter(object sender, DragEventArgs e)
            {
                e.Effect = (e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None);
            }
    
            private void listBox1_MouseDown(object sender, MouseEventArgs e)
            {
                var files = new List<OrderByMyCamera>();
                foreach (string i in listBox1.Items)
                    files.Add(new OrderByMyCamera(i));
                if(files.Count==0)
                    return;
                files.Sort();
                var filesArray = files.Select(item=>item.ToString()).ToArray();
                DoDragDrop(new DataObject(DataFormats.FileDrop, filesArray), DragDropEffects.Copy);
            }
        }
    
        internal class OrderByMyCamera : IComparable<OrderByMyCamera>
        {
            private readonly string _filePath;
            private readonly int _fileNumber;
    
            public OrderByMyCamera(string filePath)
            {
                _filePath = filePath;
                var fileName = Path.GetFileNameWithoutExtension(filePath);
                if(fileName.Count()!=6)
                    throw new Exception("Имя файла должно быть 6+4 символов вида MOVXXX.mpg. Возможно вы попытались вставить не те файлы в программу");
                if (!filePath.Trim().ToLower().EndsWith(".mpg"))
                    throw new Exception("Файлы должны заканчиваться на расширение .mpg. Сконвертируете файлы в mpeg, прежде чем вставите их в программу");
                int fileNumber = int.Parse(fileName.Substring(3), NumberStyles.HexNumber);
                _fileNumber = fileNumber;
            }
    
           public override string ToString()
            {
                return _filePath;
            }
    
            public int CompareTo(OrderByMyCamera other)
            {
                if (_fileNumber == other._fileNumber)
                    return 0;
                return (_fileNumber > other._fileNumber ? 1 : -1);
            }
        }
    }

    Говногость, 24 Июля 2011

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

    +975

    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
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    switch (Game1.mus)
                {
                    case false: sb.Draw(disabled, new Vector2(ScrW - 256, 90), Color.White); break;
                    case true: sb.Draw(enabled, new Vector2(ScrW - 256, 90), Color.White); break;
                }
                
                switch (Game1.bloooom)
                {
                    case false: sb.Draw(disabled, new Vector2(ScrW - 256, 180), Color.White); break;
                    case true: sb.Draw(enabled, new Vector2(ScrW - 256, 180), Color.White); break;
                }
                
                switch (Game1.part)
                {
                    case false: sb.Draw(disabled, new Vector2(ScrW - 256, 270), Color.White); break; //420
                    case true: sb.Draw(enabled, new Vector2(ScrW - 256, 270), Color.White); break;
                }
                
                switch (Game1.eff)
                {
                    case false: sb.Draw(disabled, new Vector2(ScrW - 256, 360), Color.White); break; //510
                    case true: sb.Draw(enabled, new Vector2(ScrW - 256, 360), Color.White); break;
                }
                switch (Game1.shad)
                {
                    case false: sb.Draw(disabled, new Vector2(ScrW - 256, 450), Color.White); break; 
                    case true: sb.Draw(enabled, new Vector2(ScrW - 256, 450), Color.White); break;
                }

    Оттуда же, откуда и #5199. Случайно обнаружил...

    RaZeR, 24 Июля 2011

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

    +973

    1. 1
    2. 2
    3. 3
    Bool IsNumber (string str) {
    return (str.Replace ("0", "").Replace ("1", "").Replace ("2", "").Replace ("3", "").Replace ("4", "").Replace ("5", "").Replace ("6", "").Replace ("7", "").Replace ("8", "").Replace ("9", "").Length == 0);
    }

    http://bash.org.ru/quote/396194

    1_and_0, 22 Июля 2011

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

    +957

    1. 1
    string lText = string.Format("{0} - VaR, Holding period: {1} days: {2}", new string[] { aConfidenceLevel.ToString("p", lNumberFormat), aHoldingPeriod.ToString(), mVARCalculator.GetVaR(aConfidenceLevel, aHoldingPeriod).ToString("n", lNumberFormat) });

    Лауреат конкурса "Отформатируй мою строку 2011". Первородный грех VB, лихо заквашенный на голландских дрожжах, не даёт автору обрести просветление в этом жестоком мире.

    kaji, 22 Июля 2011

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

    +976

    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
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    public void OpredelenieKletki(TipiReljefaMiraVelikogo tipKletkiEtt)
    {
    tipKletki = tipKletkiEtt;
     
    #region огромное назначение координат ректанглам вырезания из разнобоя
     
    if (kameraEtojKletki.sasUvelicenie)
    {
        switch (tipKletki)
        {
            case TipiReljefaMiraVelikogo.zelenaRovnaAA:
                malOcered = 1; kadrSasVirezanija = new Rectangle(0, kameraEtojKletki.sasKudaSmotrit * 79, 162, 79);
                smewenieSasKadra = new Vector2(18f, 98f); animacijaLi = false; nomRaznoboja = 19; break;
            case TipiReljefaMiraVelikogo.zelenaRovnaBB:
                malOcered = 1; kadrSasVirezanija = new Rectangle(0, 316 + kameraEtojKletki.sasKudaSmotrit * 79, 162, 79);
                smewenieSasKadra = new Vector2(18f, 98f); animacijaLi = false; nomRaznoboja = 19; break;
            case TipiReljefaMiraVelikogo.zelenaRovnaCC:
                malOcered = 1; kadrSasVirezanija = new Rectangle(0, 632 + kameraEtojKletki.sasKudaSmotrit * 79, 162, 79);
                smewenieSasKadra = new Vector2(18f, 98f); animacijaLi = false; nomRaznoboja = 19; break;
            case TipiReljefaMiraVelikogo.zelenaRovnaDD:
                malOcered = 1; kadrSasVirezanija = new Rectangle(0, 948 + kameraEtojKletki.sasKudaSmotrit * 79, 162, 79);
                smewenieSasKadra = new Vector2(18f, 98f); animacijaLi = false; nomRaznoboja = 19; break;
     
            case TipiReljefaMiraVelikogo.zelenaRovnaVertPalkaAA:
                malOcered = 1; kadrSasVirezanija = new Rectangle(0, 1264 + kameraEtojKletki.sasKudaSmotrit * 79, 162, 79);
                smewenieSasKadra = new Vector2(18f, 98f); animacijaLi = false; nomRaznoboja = 19; break;
            case TipiReljefaMiraVelikogo.zelenaRovnaVertPalkaAb:
                malOcered = 1; kadrSasVirezanija = new Rectangle(0, 1580 + kameraEtojKletki.sasKudaSmotrit * 79, 162, 79);
                smewenieSasKadra = new Vector2(18f, 98f); animacijaLi = false; nomRaznoboja = 19; break;
     
            case TipiReljefaMiraVelikogo.zelenaRovnaVertPalkaBB:
                malOcered = 1; kadrSasVirezanija = new Rectangle(162, 1264 + kameraEtojKletki.sasKudaSmotrit * 79, 162, 79);
                smewenieSasKadra = new Vector2(18f, 98f); animacijaLi = false; nomRaznoboja = 19; break;
            case TipiReljefaMiraVelikogo.zelenaRovnaVertPalkaBc:
                malOcered = 1; kadrSasVirezanija = new Rectangle(162, 1580 + kameraEtojKletki.sasKudaSmotrit * 79, 162, 79);
                smewenieSasKadra = new Vector2(18f, 98f); animacijaLi = false; nomRaznoboja = 19; break;
    
         ... ... ...

    Класс который достает из спрайтшита нужную текстуру и передает её на отрисовку.

    ArtFeel, 21 Июля 2011

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

    +107

    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
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    using System;
    
    unsafe struct A
    {
        static uint tmp;
        static int * [] vars;
    
        static void Main()
        {
            int a = 10, b = 5;
            uint[] data = Swap((uint)&a, (uint)&b);
            vars = new int * [data.Length];
    
            for (int i = 0; i < data.Length; i++)
            {
                vars[i] = (int*)data[i];
            };
        }
    
        static uint[] Swap(uint a, uint b)
        {
            tmp = a;
            a = b;
            b = tmp;
    
            return new uint[] { a, b };
        }
    };

    А ничего комментировать не буду :) Сами оценивайте степень говнокодости :)

    sexy-schmeksy, 16 Июля 2011

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

    +39

    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
    19. 19
    /// <summary>
        /// Год
        /// </summary>
        public class Year
        {
            ///<summary>
            /// Конструктор
            ///</summary>
            ///<param name="year">Год</param>
            public Year(int year)
            {
                Value = year;
            }
    
            /// <summary>
            /// Значение
            /// </summary>
            public int Value { get; set; }
        }

    qsmart, 15 Июля 2011

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

    +109

    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
    [Test]
    public void TryToParseFromIntToString()
    {
                string str="12";
                int resultat;
                bool accept=int.TryParse(str, out resultat);
                Assert.AreEqual(resultat,12);
                Assert.IsTrue(accept==true);
    }
    
    [Test]
    public void TestEqualsWhenThe2NumbersAreReallyEquals()
    {
                Assert.IsTrue(AmountComparer.Equals(123.3456m,123.3456m));
    }

    Вот такие юнит-тесты мы сегодня вычищаем! Все знаки препинания и символы сохранены ;)
    Зато всегда зеленые! ;)

    _Ru55_, 14 Июля 2011

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

    +966

    1. 1
    z = (lines[i].Substring(n.Length + 2, lines[i].Length - (n.Length + 2))).Substring(0, (lines[i].Substring(n.Length + 2, lines[i].Length - (n.Length + 2))).IndexOf("/"));

    Забавный способ вырезания домена из ссылки вида: http://www.govnokod.ru/....

    0LOL, 11 Июля 2011

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

    +954

    1. 1
    System.ComponentModel.Win32Exception: The operation completed successfully

    Из стек трейса. Не совсем говнокод, но ОЧЕНЬ смешно.

    roman-kashitsyn, 08 Июля 2011

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