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

    +140

    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
    public static Thread RunInNewThread(Action<string[]> method, string[] args, ThreadPriority priority)
    {
                Thread thread = new Thread(() => method(args));
                thread.Name = method.Method.Name;
                thread.SetApartmentState(ApartmentState.STA);
                thread.Priority = priority;
                thread.Start();
                return thread;
    }
    
    public static Thread RunInNewThread(Action<bool> method, bool args, ThreadPriority priority)
    {
                Thread thread = new Thread(() => method(args));
                thread.Name = method.Method.Name;
                thread.SetApartmentState(ApartmentState.STA);
                thread.Priority = priority;
                thread.Start();
                return thread;
    }
    
    public static Thread RunInNewThread(Action<DateTime> method, DateTime date, ThreadPriority priority)
    {
                Thread thread = new Thread(() => method(date));
                thread.Name = method.Method.Name;
                thread.SetApartmentState(ApartmentState.STA);
                thread.Priority = priority;
                thread.Start();
                return thread;
    }

    Шикарно

    taburetka, 16 Августа 2013

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

    +135

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    private readonly bool[] showDetails = new bool[20]
                                                      {
                                                          false, false, false, false, false, false, false, false, false, false,
                                                          false, false, false, false, false, false, false, false, false, false
                                                      };

    taburetka, 12 Августа 2013

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

    +133

    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
    private string LineTabsCRLFToSpaces(string line)
            {
                string ret_line = "";
                if (line != null)
                {
                    //    throw new ArgumentNullException("line");
                    if (line.Length == 0) return string.Empty;  // Пустая входная строка
                    for (int i = 0; i < line.Length; i++)
                    {
                        char ch = line[i];
                        if (ch == '\t' || ch == '\r' || ch == '\n')
                            ret_line = ret_line + " ";
                        else
                            ret_line = ret_line + ch;
                    }
                }
                return ret_line;
            }

    - line.Replce()?
    - Не, не слышал!

    nolka4, 12 Августа 2013

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

    +124

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    for (var i = 0; i < Collection.Count(); i++)
                    {
                        if (i==x)
                        {
                            Collection.Remove(i);
                        }
                    }

    Классика

    kegdan, 09 Августа 2013

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

    +137

    1. 1
    2. 2
    private static OfficerResponse ToPerson<TField, TTitle>(IEnumerable<TField> fields, IEnumerable<TTitle> titles, Func<TField, string> getName, Func<TField, string> getValue, Func<TTitle, string> getTitle, bool active, TextType1 bio, YMDType birth, ContactInformationType contactInformation, string tickers, DegreeType1[] educationHistory, CertificateType[] certifications, PositionInformationType positionInformation, AffilationType[] corporateAffiliations, string officerId, OfficerDirectorType info,string repNo)
    {...}

    нашел вот...

    fade, 08 Августа 2013

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

    +141

    1. 1
    2. 2
    3. 3
    bool eventWasRaised = false;
    
    eventWasRaised.Should().Be.False();

    иногда удивляет до чего доходят .NET unit testing фреймворки.
    пруф http://joseoncode.com/2010/04/29/event-aggregator-with-reactive-extensions/
    эту конструкцию глядишь и эксепшеном вырвет если не false.

    Irdis, 07 Августа 2013

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

    +136

    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
    int a;
    cout<<"Enter a\n";
    cin>>a;
    
    if (a==1 && a!=2 && a!=3 && a!=4 && a!=5 && a<=5)
    {
    	cout<<"Odin"<<endl;
    }
    else if (a==2 && a!=1 && a!=3 && a!=4 && a!=5 && a<=5)
    {
    	cout<<"Dva"<<endl;
    }
    else if (a==3 && a!=1 && a!=2 && a!=4 && a!=5 && a<=5)
    {
    	cout<<"Tri"<<endl;
    }
    else if (a==4 && a!=1 && a!=2 && a!=3 && a!=5 && a<=5)
    {
    	cout<<"Chetire"<<endl;
    }
    else if (a==5 && a!=1 && a!=2 && a!=3 && a!=4 && a<=5)
    {
    	cout<<"Pyat"<<endl;
    }

    как-то глянул в код соседа)

    MoN, 05 Августа 2013

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

    +105

    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
    class GeneticAlgorithm
        {
    ...
     private List<Individual> childs= new List<Individual>();
    ...
    public List<int> Genetare(....)
    {
    ......
                    childs.Clear();
                    Parallel.For(0, countOfCrossover,RandomCrossing);
                    _population.AddRange(childs);
    .....
    }
    
     private void RandomCrossing(int stateInfo)
    {
     .............
                   var child = Сrossing(parents, counOfCrossoverPoints);
                
                   childs.AddRange(child);   
     }

    Классический пример моей невнимательности.
    Приделывал параллельность в генетический алгоритм

    kegdan, 04 Августа 2013

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

    +109

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    static void Main()
    {
      int i = 0;
      Console.WriteLine(String.Format("{0} {1} {2}", i, i, i));
    }

    Я долго не видел там немного гoвна, но оказалось оно там есть

    taburetka, 02 Августа 2013

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

    +114

    1. 1
    2. 2
    3. 3
    //request.IsSecureConnection и TargetHttps - булевы переменные
    
    if (!(request.IsSecureConnection ^ TargetHttps))

    вместо if (request.IsSecureConnection == TargetHttps)

    mozg_raka, 31 Июля 2013

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