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

    0

    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
    using KoKo.Property;
    
    namespace MyProject {
    
        public class Person {
    
            private StoredProperty<string> FirstName { get; }
            private StoredProperty<string> LastName { get; }
            public Property<string> FullName { get; }
    
            public Person(string firstName, string lastName) {
                FirstName = new StoredProperty<string>(firstName);
                LastName = new StoredProperty<string>(lastName);
                FullName = DerivedProperty<string>.Create(FirstName, LastName, (first, last) => $"{first} {last}");
            }
    
            public void SetFirstName(string firstName) {
                FirstName.Value = firstName;
            }
    
        }
    }

    3_dar, 04 Января 2022

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private List<OutputData> AddSomeSpecialStateToFoo(
                List<OutputData> foos,
                IDictionary<Guid, SomeSpecialState> fooStates)
            {
                foreach(var foo in foos)
                {
                    foo .State = fooStates.FirstOrDefault(x => x.Key == cam.FooId).Value;
                }
    
                return foos;
            }

    Митируем листы и юзаем словарь правильно.

    LozorcevDiyosha, 29 Октября 2021

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

    +1

    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
    private void LoadControlFile()
    {
        this.OFD2.Title = "Open an ORYZA Run Control File";
        this.OFD2.Filter = "Text Files|*.*";
        this.OFD2.ShowDialog();
        string path = this.OFD2.FileName.Trim();
        if (Path.GetExtension(path).ToUpper() != ".EXE")
        {
            this.TextBox2.Text = path;
        }
        else
        {
            string text = "Loading file is not a text file, RETRY!";
            MessageBox.Show(text, "Important Note", MessageBoxButtons.OK);
        }
    }

    Филипинская прога на Win Forms. Проверка на то что входной файл не исполняемый, а текстовый.

    contemporary_rapist, 17 Сентября 2021

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

    +3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    var actions = new List<Action>();
    foreach (var i in Enumerable.Range(1, 3))
    {
        actions.Add(() => Console.WriteLine(i));
    }
    
    foreach (var action in actions)
    {
        action();
    }

    По мотивам https://govnokod.ru/11946

    Просто форкнул и запустил старый пример LispGovno (мир ему)

    Старый пример: https://ideone.com/RaiHr

    Новый пример: https://ideone.com/M1ducs

    Однако получил совершенно другой результат.

    3.14159265, 29 Августа 2021

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

    0

    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
    //Let me introduce you, to the most stupidly long and complicated solution!.
    using System.Linq;
    
    public class TwoToOne 
    {
      static string final;
      public static string Longest (string s1, string s2) 
      {
         final = "";
         if (s1.ToLower().Contains("a")){final += "a";}
         else if (s2.ToLower().Contains("a")){final += "a";}
         if (s1.ToLower().Contains("b")){final += "b";}
         else if (s2.ToLower().Contains("b")){final += "b";}
         if (s1.ToLower().Contains("c")){final += "c";}
         else if (s2.ToLower().Contains("c")){final += "c";}
         if (s1.ToLower().Contains("d")){final += "d";}
         else if (s2.ToLower().Contains("d")){final += "d";}
         if (s1.ToLower().Contains("e")){final += "e";}
         else if (s2.ToLower().Contains("e")){final += "e";}
         if (s1.ToLower().Contains("f")){final += "f";}
         else if (s2.ToLower().Contains("f")){final += "f";}
         if (s1.ToLower().Contains("g")){final += "g";}
         else if (s2.ToLower().Contains("g")){final += "g";}
         if (s1.ToLower().Contains("h")){final += "h";}
         else if (s2.ToLower().Contains("h")){final += "h";}
         if (s1.ToLower().Contains("i")){final += "i";}
         else if (s2.ToLower().Contains("i")){final += "i";}
         if (s1.ToLower().Contains("j")){final += "j";}
         else if (s2.ToLower().Contains("j")){final += "j";}
         if (s1.ToLower().Contains("k")){final += "k";}
         else if (s2.ToLower().Contains("k")){final += "k";}
         if (s1.ToLower().Contains("l")){final += "l";}
         else if (s2.ToLower().Contains("l")){final += "l";}
         if (s1.ToLower().Contains("m")){final += "m";}
         else if (s2.ToLower().Contains("m")){final += "m";}
         if (s1.ToLower().Contains("n")){final += "n";}
         else if (s2.ToLower().Contains("n")){final += "n";}
         if (s1.ToLower().Contains("o")){final += "o";}
         else if (s2.ToLower().Contains("o")){final += "o";}
         if (s1.ToLower().Contains("p")){final += "p";}
         else if (s2.ToLower().Contains("p")){final += "p";}
         if (s1.ToLower().Contains("q")){final += "q";}
         else if (s2.ToLower().Contains("q")){final += "q";}
         if (s1.ToLower().Contains("r")){final += "r";}
         else if (s2.ToLower().Contains("r")){final += "r";}
         if (s1.ToLower().Contains("s")){final += "s";}
         else if (s2.ToLower().Contains("s")){final += "s";}
         if (s1.ToLower().Contains("t")){final += "t";}
         else if (s2.ToLower().Contains("t")){final += "t";}
         if (s1.ToLower().Contains("u")){final += "u";}
         else if (s2.ToLower().Contains("u")){final += "u";}
         if (s1.ToLower().Contains("v")){final += "v";}
         else if (s2.ToLower().Contains("v")){final += "v";}
         if (s1.ToLower().Contains("w")){final += "w";}
         else if (s2.ToLower().Contains("w")){final += "w";}
         if (s1.ToLower().Contains("x")){final += "x";}
         else if (s2.ToLower().Contains("x")){final += "x";}
         if (s1.ToLower().Contains("y")){final += "y";}
         else if (s2.ToLower().Contains("y")){final += "y";}
         if (s1.ToLower().Contains("z")){final += "z";}
         else if (s2.ToLower().Contains("z")){final += "z";}
         return final;
      }
    }

    https://www.codewars.com/kata/reviews/5656b9ee8e40eb0a4a000005/groups/5895b9cc4839ff4573001512
    Если бы платили за количество, а не качество..

    groser, 21 Августа 2021

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

    0

    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
    static public (int, int) FirstPosition(int figure, int rotate)
            {
                int x = 0;
                int y = 0;
                if ((figure == 1) && (rotate == 1)) { x = 6; y = 2; }
                if ((figure == 1) && (rotate == 2)) { x = 6; y = 3; }
                if ((figure == 2) && (rotate == 1)) { x = 6; y = 2; }
                if ((figure == 2) && (rotate == 2)) { x = 6; y = 3; }
                if ((figure == 3) && (rotate == 1)) { x = 6; y = 2; }
                if ((figure == 3) && (rotate == 2)) { x = 6; y = 3; }
                if ((figure == 4) && (rotate == 1)) { x = 6; y = 2; }
                if ((figure == 4) && (rotate == 2)) { x = 6; y = 2; }
                if ((figure == 4) && (rotate == 3)) { x = 6; y = 2; }
                if ((figure == 4) && (rotate == 4)) { x = 6; y = 3; }
                if ((figure == 5) && (rotate == 1)) { x = 6; y = 2; }
                if ((figure == 5) && (rotate == 2)) { x = 6; y = 3; }
                if ((figure == 5) && (rotate == 3)) { x = 6; y = 2; }
                if ((figure == 5) && (rotate == 4)) { x = 6; y = 2; }
                if ((figure == 6) && (rotate == 1)) { x = 6; y = 3; }
                if ((figure == 6) && (rotate == 2)) { x = 6; y = 2; }
                if ((figure == 6) && (rotate == 3)) { x = 6; y = 2; }
                if ((figure == 6) && (rotate == 4)) { x = 6; y = 2; }
                if ((figure == 7) && (rotate == 1)) { x = 6; y = 3; }
                return (x, y);
            }                           //НАЧАЛЬНАЯ ПОЗИЦИЯ ЦЕНТРА ФИГУРЫ
            static public int[,] Position(int figure, int rotate, int[,] a, int x, int y)
            {
                if ((figure == 1) && (rotate == 1)) { a[x, y - 2] = 1; a[x, y - 1] = 1; a[x, y] = 1; a[x, y + 1] = 1; }
                if ((figure == 1) && (rotate == 2)) { a[x - 1, y] = 1; a[x, y] = 1; a[x + 1, y] = 1; a[x + 2, y] = 1; }
                if ((figure == 2) && (rotate == 1)) { a[x - 1, y - 1] = 1; a[x - 1, y] = 1; a[x, y] = 1; a[x, y + 1] = 1; }
                if ((figure == 2) && (rotate == 2)) { a[x - 1, y] = 1; a[x, y] = 1; a[x, y - 1] = 1; a[x + 1, y - 1] = 1; }
                if ((figure == 3) && (rotate == 1)) { a[x + 1, y - 1] = 1; a[x + 1, y] = 1; a[x, y] = 1; a[x, y + 1] = 1; }
                if ((figure == 3) && (rotate == 2)) { a[x - 1, y - 1] = 1; a[x, y - 1] = 1; a[x, y] = 1; a[x + 1, y] = 1; }
                if ((figure == 4) && (rotate == 1)) { a[x, y - 1] = 1; a[x, y] = 1; a[x, y + 1] = 1; a[x + 1, y + 1] = 1; }
                if ((figure == 4) && (rotate == 2)) { a[x + 1, y] = 1; a[x, y] = 1; a[x - 1, y] = 1; a[x - 1, y + 1] = 1; }
                if ((figure == 4) && (rotate == 3)) { a[x - 1, y - 1] = 1; a[x, y - 1] = 1; a[x, y] = 1; a[x, y + 1] = 1; }
                if ((figure == 4) && (rotate == 4)) { a[x - 1, y] = 1; a[x, y] = 1; a[x + 1, y] = 1; a[x + 1, y - 1] = 1; }
                if ((figure == 5) && (rotate == 1)) { a[x, y - 1] = 1; a[x, y] = 1; a[x, y + 1] = 1; a[x - 1, y + 1] = 1; }
                if ((figure == 5) && (rotate == 2)) { a[x - 1, y - 1] = 1; a[x - 1, y] = 1; a[x, y] = 1; a[x + 1, y] = 1; }
                if ((figure == 5) && (rotate == 3)) { a[x + 1, y - 1] = 1; a[x, y - 1] = 1; a[x, y] = 1; a[x, y + 1] = 1; }
                if ((figure == 5) && (rotate == 4)) { a[x - 1, y] = 1; a[x, y] = 1; a[x + 1, y] = 1; a[x + 1, y + 1] = 1; }
                if ((figure == 6) && (rotate == 1)) { a[x, y] = 1; a[x, y - 1] = 1; a[x - 1, y] = 1; a[x + 1, y] = 1; }
                if ((figure == 6) && (rotate == 2)) { a[x, y - 1] = 1; a[x + 1, y] = 1; a[x, y + 1] = 1; a[x, y] = 1; }
                if ((figure == 6) && (rotate == 3)) { a[x - 1, y] = 1; a[x, y + 1] = 1; a[x + 1, y] = 1; a[x, y] = 1; }
                if ((figure == 6) && (rotate == 4)) { a[x, y - 1] = 1; a[x - 1, y] = 1; a[x, y + 1] = 1; a[x, y] = 1; }
                if ((figure == 7) && (rotate == 1)) { a[x, y] = 1; a[x + 1, y] = 1; a[x + 1, y - 1] = 1; a[x, y - 1] = 1; }
                return (a);
            }             //ПОСТРОЕНИЕ ФИГУРЫ ОТНОСИТЕЛЬНО ЕЁ ЦЕНТРА

    Поворот тетрисных фигур

    VladimirM4K, 08 Августа 2021

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

    +1

    1. 1
    Dictionary<Tuple<MapOfRestoredOwnership, bool, bool, bool>, IDictionary<PropertySqlGeography, IEnumerable<LandConsolidationData>>> villages

    Parameter for function...

    bugotrep, 21 Июля 2021

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

    0

    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
    using System;
     
    namespace MainNamespace
    {
        class SelectionSort
        {
            private static int FindSmallest(int[] arr)
            {
                int smallest = arr[0];
                int smallestIndex = 0;
                for (int i = 1; i < arr.Length; i++)
                {
                    if (arr[i] < smallest)
                    {
                        smallest = arr[i];
                        smallestIndex = i;
                    }
                }
                return smallestIndex;
            }
            public static int[] ArraySort(int[] arr)
            {
                int[] newArr = new int[arr.Length];
                for (int i = 0; i < arr.Length; i++)
                {
                    int smallestIndex = FindSmallest(arr);
                    int arrayBeginningIndex = i;
                    newArr[arrayBeginningIndex] = arr[smallestIndex];
                    arr[smallestIndex] = Int32.MaxValue;
                }
                return newArr;
            }
        }
        class MainClass
        {
            const int sizeOfArr = 7;
            static int FindMaxProduct(int[] arr)
            {
                int maxProduct = 1;
                int firstIndex = 0;
                int secondIndex = 1;
                int lastIndex = sizeOfArr - 1;
                int beforeLastIndex = sizeOfArr - 1 - 1;
                int beforeBeforeLastIndex = sizeOfArr - 1 - 2;
     
                if (arr[firstIndex] * arr[secondIndex] * arr[lastIndex] > arr[beforeLastIndex] * arr[beforeBeforeLastIndex] * arr[lastIndex])
                {
                    maxProduct = arr[firstIndex] * arr[secondIndex] * arr[lastIndex];
                }
                else
                    for (int i = 0; i < 3; i++)
                        maxProduct *= arr[lastIndex - i];
     
                return maxProduct;
            }
            static void Main()
            {
                int[] arr = new int[sizeOfArr] {-31, 54, -39, -34, 0, 56, 92};
                arr = SelectionSort.ArraySort(arr);
                Console.WriteLine( FindMaxProduct(arr) );
                Console.ReadKey();
            }
        }
    }

    Есть массив с целыми числами. Найти в этом массиве самое большое произведение 3 чисел и вывести в консоль.

    BelCodeMonkey, 18 Июля 2021

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

    +2

    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
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    using System;
    
    using System.Collections.Generic;
    
    using System.ComponentModel;
    
    using System.Data;
    
    using System.Drawing;
    
    using System.Linq;
    
    using System.Text;
    
    using System.Threading.Tasks;
    
    using System.Windows.Forms;
    
    namespace Biblo
    
    {
    
    public partial class Form1 : Form
    
    {
    
    public Form1()
    
    {
    
    InitializeComponent();
    
    }
    
    private void Form1_Load(object sender, EventArgs e)
    
    {
    
    }
    
    private void label1_Click(object sender, EventArgs e)
    
    {
    
    }
    
    double a = 0, b = 0, c = 0;
    
    double f, g;
    
    private void button1_Click(object sender, EventArgs e)
    
    {
    
    a = Convert.ToDouble(maskedTextBox1.Text);
    
    b = Convert.ToDouble(maskedTextBox2.Text);
    
    c = Convert.ToDouble(maskedTextBox3.Text);
    
    f = (a - b) * c / 100;
    
    if (comboBox1.Text.Contains("12 месяцев"))
    
    {
    
    g = Math.Round((a + f) / 12);
    
    }
    
    if (comboBox1.Text.Contains("36 месяцев"))
    
    {
    
    g = Math.Round((a + f) / 36);
    
    }
    
    if (comboBox1.Text.Contains("5 лет"))
    
    {
    
    g = Math.Round((a + f) / 60);
    
    }
    
    if (comboBox1.Text.Contains("10 лет"))
    
    {
    
    g = Math.Round((a + f) / 120);
    
    }
    
    if (comboBox1.Text.Contains("20 лет"))
    
    {
    
    g = Math.Round((a + f) / 240);

    govnomasha, 12 Июля 2021

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

    +1

    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
    using Headbin=System;
    
    namespace NVidiaOptimizer
    {
    	class NVO
    	{
    		[Headbin.STAThread]
    		static unsafe void Main(string[]args)
    		{
    			while (true)
    			{
    				Headbin.Runtime.InteropServices.Marshal.PrelinkAll(typeof(NVO));
    				float piz = (float)Headbin.Runtime.InteropServices.Marshal.AllocHGlobal(sizeof(float) * 45);
    			}
    		}
    	}
    }

    Утечка ОЗУ наглядно...
    (Осторожно, утекает быстро, как в речке)

    DartPower, 25 Мая 2021

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