- 1
- 2
- 3
- 4
- 5
- 6
// тухло
if (json.Contains("message"))
{
classOperatios.ResultOper2 result2 = JsonConvert.DeserializeObject<classOperatios.ResultOper2>(json);
MessageBox.Show(result2.message + (char)13 + (char)10 + result2.errors);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
// тухло
if (json.Contains("message"))
{
classOperatios.ResultOper2 result2 = JsonConvert.DeserializeObject<classOperatios.ResultOper2>(json);
MessageBox.Show(result2.message + (char)13 + (char)10 + result2.errors);
}
Царский код. Как склеить две строки с разделителем "новая строка".
0
//Breakpoint
bool[] bp = new bool[1]; bp[1] = true;
Чувак сказал, что так ему удобнее.
−6
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace sortQuick {class quickSort{
private int[] array = new int[20]; ;; private int len;
public void QuickSort() {sort(0, len - 1);}
public void sort(int left, int right){int pivot, leftend, rightend;
leftend = left;
rightend = right;
pivot = array[left];
while (left < right){
while ((array[right] >= pivot) && (left < right)){right--;}if (left != right) {
array[left] = array[right]; left++;}
while ((array[left] <= pivot) && (left < right)){
left++;}
if (left != right){array[right] = array[left];right--;}}
array[left] = pivot;pivot = left;
left = leftend;
right = rightend;
if (left < pivot)
{sort(left, pivot - 1);}
if (right > pivot){sort(pivot + 1, right);}}
public static void Main(){
quickSort q_Sort = new quickSort();
int[] array = { 4, 3, 1, 4, 6, 7, 5, 4, 32, 5, 26, 187, 8 };
q_Sort.array = array;
q_Sort.len = q_Sort.array.Length;
q_Sort.QuickSort();
for (int j = 0; j < q_Sort.len; j++){Console.WriteLine(q_Sort.array[j]);}
Console.ReadKey();}}}
Мучайтесь си диезники хреновы
−2
int[][] arr = new int[3][];
arr[0] = new int[3];
arr[1] = new int[2];
arr[2] = new int[5];
arr[0][2] = 16;
arr[1][0] = 45;
arr[2][4] = 99;
foreach (int item in arr[0])
Console.Write(item + " ");
Console.WriteLine();
foreach (int item in arr[1])
Console.Write(item + " ");
Console.WriteLine();
foreach (int item in arr[2])
Console.Write(item + " ");
Этот foreach просто божественен
−1
Нах c#, если есть Java?
0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
/**
* Extension to simplify code writing
*/
static string Read()
{
return Console.ReadLine();
}
static void Print(string val, bool newline)
{
if(newline)
{
Console.WriteLine(val);
}
else
{
Console.Write(val);
}
}
static void Print(double val, bool newline)
{
if(newline)
{
Console.WriteLine(val.ToString());
}
else
{
Console.Write(val.ToString());
}
}
static void Print(bool val, bool newline)
{
if(newline)
{
Console.WriteLine(val.ToString());
}
else
{
Console.Write(val.ToString());
}
}
static void Print(int val, bool newline)
{
if(newline)
{
Console.WriteLine(val.ToString());
}
else
{
Console.Write(val.ToString());
}
}
/**
* End of extension
*/
static int ToBase(int number, int nbase = 2)
{
int converted = 0;
if(number == 0)
{
return 0;
}
else
{
while(number > 0)
{
converted = converted * 10 + (number % nbase);
number /= nbase;
}
}
return converted.ToString().Reverse().Aggregate(0, (b, x) => 10 * b + x - '0');
}
/** Use:
* The first number is the convertable
* The second is the base
*/
static void Main(string[] args)
{
int num = int.Parse(Read());
int nnbase = int.Parse(Read());
Print("The number is: ", false);
Print(num, true);
Print("The base is: ", false);
Print(nnbase, true);
Print("The conv. number is: ", false);
Print(ToBase(num, nnbase), true);
}
}
}
Говно ли это? Конвертит числа
0
Ненавижу "Console.WriteLine("something");", "Cube coin = new Cube(2);" и "int[ , ] arr = new int[2,3];".
В крестах все проще: "cout << "something";", "Cube coin(2);" и "int arr[2,3];".
Для меня идеальным языком был бы сисярп с синтаксисом крестов.
0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
/* The "Enter le ..." thing
is left for Шindows compilers.
Don't mind it. */
namespace SoloLearn
{
public class Program
{
public static void Main(string[] args)
{
int a = 0;
int b = 0; //Declare two numbers
string leChar; //Declare the character
int sum; //Declare the place where the result of the expression would be stored
Console.WriteLine("Enter le first number\n");
string c = a.ToString(); //Convert the 1st № to string
c = Console.ReadLine(); //Assign the 1st number
Console.WriteLine("Enter le character\n");
leChar = Console.ReadLine(); //Assign the char
Console.WriteLine("Enter le second number\n");
string d = b.ToString(); //Convert the 2nd № to string
d = Console.ReadLine(); //Assign the second number
a = System.Convert.ToInt16(c);
b = System.Convert.ToInt16(d);
sum = Calculate(a,leChar,b); //Calculate
Console.WriteLine("{0} {1} {2} is {3}", a, leChar, b, sum);
}
public static int Calculate(int x, string z, int y) {
int qwerty = 0;
switch(z) {
case "+": //Case of addition
qwerty = x + y;
break;
case "-": //Case of subtraction
qwerty = x - y;
break;
case "*": //Case of multiplication
qwerty = x * y;
break;
case "/": //Case of division
qwerty = x / y;
break;
}
return qwerty; //If smth = Calculate(parameters), var smth would have the content of this var © Your Captain Obvious
}
}
}
Выдавил из себя где-то месЕц назад. Как я умудрялся делать 2 переменные для просто стринговых версий существующих переменных только для того, чтобы прочитать инпут? Хорошо, что в сисярпе есть гарбаж коллектор. И да, названия переменных во второй функции - прекрасные (посмотрите: x, y, z, qwerty - не прекрасно ли?) говГо.
0
using System;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Linq;
using System.Collections.Generic;
namespace CSharp_Shell
{
public class Program
{
static int flipACoin() {
Random rand = new Random();
int coin = rand.Next(0,2);
return coin;
}
public static void Main(string[] args)
{
int headsCount = 0;
int tailsCount = 0;
int tmp;
Console.Write("Enter a number of flips\n");
for(int flips = int.Parse(Console.ReadLine()); flips > 0; flips--)
{
Console.Write("You flipped: ");
tmp = flipACoin();
if(tmp == 1)
{
Console.Write("Heads\n");
headsCount++;
}
else
{
Console.Write("Tails\n");
tailsCount++;
}
}
Console.Write("Heads: " + headsCount + "\nTails: " + tailsCount + "\n");
}
}
}
Флипает коинсу по аглицки. Есть ли это говнокодом?
−2
Как покласть в exception этот сайт:
1. Заходим в форму регистрации
2. Вводим данные: Ник //, мыло любое, пароль /*, подтверждение */
3. ???
4. PROFIT!