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

    +115

    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
    private object[] select ( string tablename, Type type, string addict ) 
            {
                object[] returned_objects = new object[0];
                string sql = "SELECT ";
                sql += this.buildFieldNames( type );
                sql += " FROM `" + tablename + "`" + addict;
                MySqlDataReader reader = this.TryQueryReader( sql );
                while (reader.Read( ))
                {
                    var obj = Activator.CreateInstance( type );
                    FieldInfo[] fields = type.GetFields( );
                    foreach (FieldInfo finfo in fields)
                    {
                        if (finfo.FieldType == typeof( int ))
                        {
                            finfo.SetValue( obj, reader.GetInt32( finfo.Name ) );
                        }
                        else if (finfo.FieldType == typeof( bool ))
                        {
                            if (reader.GetString( finfo.Name ).Equals( "true" ))
                            {
                                finfo.SetValue( obj, true );
                            }
                            else
                            {
                                finfo.SetValue( obj, false );
                            }
                        }
                        else if (finfo.FieldType == typeof( float ))
                        {
                            finfo.SetValue( obj, reader.GetFloat( finfo.Name ) );
                        }
                        else if (finfo.FieldType == typeof( double ))
                        {
                            finfo.SetValue( obj, reader.GetDouble( finfo.Name ) );
                        }
                        else if (finfo.FieldType == typeof( string ))
                        {
                            finfo.SetValue( obj, reader.GetString( finfo.Name ) );
                        }
                    }
                    provider.IncreaseLength( ref returned_objects, 1 );
                    returned_objects.SetValue( obj, returned_objects.Length - 1 );
    
                }
                reader.Close( );
                return returned_objects;
            }

    самопальный орм, нот комментс

    glilya, 30 Мая 2011

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

    +120

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    using System;
    
    class C
    {
        static void Main()
        {
            क्ष(0);
        }
    
        static void क्‍ष(int x) { Console.WriteLine(1); }
        static void क्ष(object x) { Console.WriteLine(2); }
    }

    Что будет напечатано ?


    Оч понравилось, нашел на простора интырнета (пардон если повтор)

    glilya, 28 Мая 2011

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

    +111

    Monkeys scripting

    просто гет

    bugmenot, 18 Мая 2011

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

    +128

    1. 1
    long.Parse(Convert.ToString(Convert.ToSingle(Item.Value.ToString())))

    wiz, 17 Мая 2011

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

    +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
    if (comboBox1.SelectedItem.ToString() == "VISA")
                {
                    pictureBox7.Visible = false;
                    pictureBox6.Visible = false;
                    pictureBox5.Visible = false;
                    pictureBox4.Visible = false;
                    pictureBox3.Visible = false;
                    pictureBox2.Visible = false;
                    pictureBox1.Visible = true;
                }
                if (comboBox1.SelectedItem.ToString() == "MasterCard")
                {
                    pictureBox7.Visible = false;
                    pictureBox6.Visible = false;
                    pictureBox5.Visible = false;
                    pictureBox4.Visible = false;
                    pictureBox3.Visible = false;
                    pictureBox1.Visible = false;
                    pictureBox2.Visible = true;
                }

    + ещй пять такие проверок. Ну не умеет человек PictureBox.Image пользоваться.

    Killster, 16 Мая 2011

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

    +119

    1. 1
    2. 2
    3. 3
    4. 4
    foreach (var list in Distances.ConvertToList())
    {
         dt.Rows.Add(ConvertToObject(list.ToArray()));
    }

    dotnetdeveloper, 12 Мая 2011

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

    +122

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    var rl2 = _vf.AddNewRouteLine(BusStation.Instance.GetRoute(
    BusStation.Instance.FindSettlement(БарановичиcheckBox6.Content.ToString()),
    BusStation.Instance.FindSettlement(БобруйскcheckBox17.Content.ToString()))[0],
    БарановичиcheckBox6, БобруйскcheckBox17, Upd);
    canvas1.Children.Add(rl2.Line);

    dotnetdeveloper, 12 Мая 2011

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

    +116

    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
    IList<Hashtable> records = crit.List<Hashtable>();
    Guid[] personsId = records.Select(item => (Guid)item["PersonID"]).Distinct().ToArray();
    List<EmployeeData> empDatas = new List<EmployeeData>();
    
    foreach(Guid personId in personsId) {
    	IEnumerable<Hashtable> employeeRecords = records.Where(item => (Guid)item["PersonID"] == personId);
    	Hashtable employeeRecord = employeeRecords.FirstOrDefault(item => !(bool)item["IsLoad"] || (DateTime)item["EventDate"] == employeeRecords.Max(unit => (DateTime)unit["EventDate"]));
    
    	Hashtable employeeRecordAddition = new GenericNHibernateDao<BaseDocument>().CreateCriteria()
    		.CreateAlias("Department", "department")
    		.CreateAlias("Employee", "employee")
    		.CreateAlias("WorkDescription.Schedule", "schedule", JoinType.LeftOuterJoin)
    		.CreateAlias("WorkDescription.EmployeeApperance", "employeeApperance", JoinType.LeftOuterJoin)
    		.Add(Restrictions.Eq("EmployeeStamp.TabNo", employeeRecord["TabNo"]))
    		.Add(Restrictions.Eq("IsHalf", false))
    	...
    }

    No comments %)

    Guid, 12 Мая 2011

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

    +120

    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
    private string GetConnectionString() 
        { 
          string connString = String.Empty; 
          string location = Assembly.GetExecutingAssembly().Location; 
          int pos = location.LastIndexOf('\\'); 
          location = location.Remove(pos); 
          pos = location.LastIndexOf('\\'); 
          location = location.Remove(pos); 
          pos = location.LastIndexOf('\\'); 
          location = location.Remove(pos); 
          location += @"\server\conf\config.conf"; 
          using (StreamReader sr = File.OpenText(location)) 
          { 
            string s = ""; 
            while ((s = sr.ReadLine()) != null) 
            { 
              connString += s; 
            } 
          } 
          connString += "database = ***; charset = utf8;"; 
          return connString; 
        }

    mahalex, 11 Мая 2011

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

    +115

    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
    ----Something.cs
    public partial class Something
    {
      // some implementation.
    }
    ----Something.Bla.cs
    partial class Something
    {
      private class Bla
      {
      }
    }
    ----Something.Foo.cs
    partial class Something
    {
      private class Foo
      {
      }
    }
    ----Something.Bar.cs
    partial class Something
    {
      private class Bar
      {
      }
    }

    Нормально ли использовать partial классы исключительно для хранения private nested классов? К примеру если количество таковых доходит до 5-15?

    walash, 11 Мая 2011

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