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

    +130

    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
    <li  style="margin-top: 17px;" class="buy">
      <a href="@Model.WebSiteUrl" target="_blank" style="color: #12BBFF; display:block;">
        Buy on @Model.WebSiteUrlShort for [email protected]
      </a>
      <div id="idProductUrls">
        @foreach(string url in Model.ProductUrls)
        {
          <a href="@url" target="_blank" style="color: #12BBFF; display:block;">
          </a>
        }
      </div>
    </li>
    <script type="text/javascript">
      $('#idProductUrls a').each(
         function () {
           this.innerHTML = get_hostname($(this).attr('href'));
         }
      );
    </script>

    Джуниор перенес часть функционала на клиент, а именно текст ссылки создается на клиенте

    DarkThinker, 29 Апреля 2013

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

    +131

    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
    class Date
        {
            private DateTime date;
            public Date(int day,int month,int year)
            {
                if(month > 0 && month < 13 && day > 0 && day <= DateTime.DaysInMonth(year,month)) // Это не надо, моё введение.
                    date = new DateTime(year,month,day);
                else Console.WriteLine("Неверная дата.");//
            }
            public Date()
            {
                date= new DateTime(2009,01,01);
            }
            public DateTime Yesterday()
            {
                return date.AddDays(-1);
            }
            public DateTime NextDay()
            {
                return date.AddDays(1);
            }
            public int Days()
            {
                return DateTime.DaysInMonth(date.Year,date.Month)-date.Day;
            }
            public DateTime GetDate
            {
                get
                {
                    return date;
                }
                set
                {
                    date = value;
                }
            }
            public bool IsLeapYear
            {
                get
                {
                    return DateTime.IsLeapYear(date.Year);
                }
            }
        }

    Пришлось сделать.

    dos_, 27 Апреля 2013

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

    +132

    1. 1
    TempClass.Area = Convert.ToDecimal(dt.Rows[0]["Area"].ToString()).ToString("F1", CultureInfo.CreateSpecificCulture("en-US"));

    Про string.format видимо мы не знаем....

    bars, 27 Апреля 2013

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

    +138

    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
    public bool ParsеOboznString(string obozn)
            {
                Thread.CurrentThread.CurrentCulture = new CultureInfo("ru-RU");  // Установка русской культуры
    
                try
                {
                    Regex reg = new Regex(@"(\D*)(\d*)([^\+]*)[\+]?(\d+[,]\d+)*");    // регулярное выражение
                    Match m = reg.Match(obozn);                                                            // разбор строки обозначения
                    ....
                    ....
                    ....
                }
                catch
                {
                    return false;
                }
    
                return true;
            }

    "культурный" код и "содержательные" комментарии

    diimdeep , 22 Апреля 2013

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

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if (best == null)
                {
                    return null;
                }
                else
                {
                    return best;
                }

    Psilon, 19 Апреля 2013

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

    +137

    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
    if (curMenu != null)
    {
      depth = curMenu.Depth;
      Menu menuG = null;
      if (depth == 1)
      {
        menuG = curMenu;
      }
      if (depth == 2)
      {
        menuG = curMenu.Menu2;
      }
      if (depth == 3)
      {
        menuG = curMenu.Menu2.Menu2;
      }
      if (depth == 4)
      {
        menuG = curMenu.Menu2.Menu2.Menu2;
      }
      if (depth == 5)
      {
        menuG = curMenu.Menu2.Menu2.Menu2.Menu2;
      }
      if (depth == 6)
      {
        menuG = curMenu.Menu2.Menu2.Menu2.Menu2.Menu2;
      }
      if (depth == 7)
      {
        menuG = curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2;
      }
      if (depth == 8)
      {
        menuG = curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2;
      }
    }

    Nested set для петухов!

    validol, 19 Апреля 2013

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

    +132

    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
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    <div class="breadcrumbs">
      <ul>
        <li>
          @if (curMenu != null)
          {
            <a href="@Url.Action("index", "main")">Главная</a><span class="breadcrumbs__dash"> / </span>
            if (depth == 1)
            {
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 2)
            {
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a> <span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 3)
            {
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 4)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 5)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 6)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 7)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 8)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }                                  
          }
          else if (ViewBag.Title != null && url!="/")
          {
            <a href="@Url.Action("index", "main")">Главная</a><span class="breadcrumbs__dash"> / </span>
            <span>@ViewBag.Title</span>
          }
        </li>
      </ul>
    </div>

    Хлебные крошки в каталоге "неограниченной" вложенности.

    validol, 19 Апреля 2013

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

    +100

    1. 1
    DateTime.Now.ToString("HH:mm:ss.ffffff").Replace(":", "").Replace(".", "")

    facepalm

    kore_sar, 18 Апреля 2013

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

    +111

    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
    public static void kk(int KEY, int[] Q, ref int x)
            {
                if (KEY <= Q[4095]) // 0-4095
                {
                    if (KEY <= Q[2047]) // 0-2047
                    {
                        if (KEY <= Q[1023]) // 0-1023
                        {
                            if (KEY <= Q[511]) // 0-511
                            {
                                if (KEY <= Q[255]) // 0-255
                                {
                                    if (KEY <= Q[127]) // 0-127
                                    {
                                        if (KEY <= Q[63]) // 0-63
                                        {
                                            if (KEY <= Q[31]) // 0-31
                                            {
                                                if (KEY <= Q[15]) // 0-15
                                                {
                                                    if (KEY <= Q[7]) // 0-7
                                                    {
                                                        if (KEY <= Q[3]) // 0-3
                                                        {
                                                            if (KEY <= Q[1]) // 0-1
                                                            {
                                                                if (KEY <= Q[0]) x = 0;
                                                                else x = 1;
                                                            } // end 0-1
                                                            else  //2-3
                                                            {
                                                                if (KEY <= Q[2]) x = 2;
                                                                else x = 3;
                                                            } // end 2-3
                                                        } // end 0-3
    .................................................................

    С форума sql.ru: "......есть адский статический метод на 33.000 строк...."

    grobotron, 15 Апреля 2013

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

    +100

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    int i = 0;
    foreach (SomeType item in someCollection)
    {
        if (i > 0) break;
    
        // ... обрабатываем item
    }

    Берём первый элемент коллекции и обрабатываем...

    kore_sar, 15 Апреля 2013

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