- 1
System.Drawing.Color.FromArgb(((int)(((byte)(249)))), ((int)(((byte)(249)))), ((int)(((byte)(249)))));
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+137
System.Drawing.Color.FromArgb(((int)(((byte)(249)))), ((int)(((byte)(249)))), ((int)(((byte)(249)))));
+132
var yetUsed = new HashSet<int>(startFrom ?? new int[] { })
/*..............................................................................................................................*/
foreach (var ind in Enumerable.Range(0, proxy.Size).Where(yetUsed.Contains))
{
proxy.SetIndexes(yetUsed.Where(x=>x!= ind).OrderBy(x => x).ToArray());
/* ............................................................................*/
}
/*.......................................................................................................................*/
Из разряда
int i = 3;
"3" == i.ToString();
+105
//Невероятные приключения Microsoft'а в Индии:
private string ExtractHttpVerb(XmlDocument configDOM)
{
string httpVerb;
string hv = IfExistsExtract(configDOM, "/Config/method", "2");
switch (hv)
{
case "0":
httpVerb = HttpVerbs[0];
break;
case "1":
httpVerb = HttpVerbs[1];
break;
case "2":
httpVerb = HttpVerbs[2];
break;
default:
httpVerb = HttpVerbs[2];
break;
}
return httpVerb;
}
+123
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (!Char.IsDigit(e.KeyChar) && !(Char.IsControl(e.KeyChar)))
{
if (!((e.KeyChar.ToString() == ",") && (textBox1.Text.IndexOf(",") == -1)))
e.Handled = true;
}
}
private void textBox2_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (!Char.IsDigit(e.KeyChar) && !(Char.IsControl(e.KeyChar)))
{
if (!((e.KeyChar.ToString() == ",") && (textBox2.Text.IndexOf(",") == -1)))
e.Handled = true;
}
}
Увидел у соседа по комнате книжку на полке '"C# в задачах и примерах"
открываю, а там это
первая надпись в книге - Процесс создания программы состоит из 2 шагов - создание формы и создания функций обработки.
ООАиП, иди ты нахуй!
+136
public int GetModuleId(int userId)
{
return moduleIdGet(userId);
}
protected int moduleIdGet(int userId)
{
int moduleId;
// calculate moduleId
// ...
return moduleId;
}
Дал открытый доступ, но в то же время как бы сохранил защищённый.
+135
FileInfo[] fi = new DirectoryInfo(di.FullName).GetFiles();
var creationList = from file in fi
where file.CreationTime.CompareTo(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day)) < 0 //This instance is earlier than value.
group file.CreationTime by DateTime.Parse(file.CreationTime.ToString("yyyy-MM-dd")) into ct
select ct.Key;
что делает этот код?
+124
static class FuncExtention
{
public static Func<T1, Func<T2, T3>> Carry<T1, T2, T3>(this Func<T1, T2, T3> func)
{
return t1 => t2 => func(t1, t2);
}
public static Func<T1, Func<T2, Func<T3, T4>>> Carry<T1, T2, T3, T4>(this Func<T1, T2, T3, T4> func)
{
return t1 => t2 => t3 => func(t1, t2, t3);
}
public static Func<T1, Func<T2, Func<T3, Func<T4, T5>>>> Carry<T1, T2, T3, T4, T5>(this Func<T1, T2, T3, T4, T5> func)
{
return t1 => t2 => t3 => t4 => func(t1, t2, t3, t4);
}
public static Func<T1, Func<T2, Func<T3, Func<T4, Func<T5, T6>>>>> Carry<T1, T2, T3, T4, T5, T6>(this Func<T1, T2, T3, T4, T5, T6> func)
{
return t1 => t2 => t3 => t4 => t5 => func(t1, t2, t3, t4, t5);
}
public static Func<T1, Func<T2, Func<T3, Func<T4, Func<T5, Func<T6, T7>>>>>> Carry<T1, T2, T3, T4, T5, T6, T7>(this Func<T1, T2, T3, T4, T5, T6, T7> func)
{
return t1 => t2 => t3 => t4 => t5 => t6 => func(t1, t2, t3, t4, t5, t6);
}
public static Func<T1, Func<T2, Func<T3, Func<T4, Func<T5, Func<T6, Func<T7, T8>>>>>>> Carry<T1, T2, T3, T4, T5, T6, T7, T8>(this Func<T1, T2, T3, T4, T5, T6, T7, T8> func)
{
return t1 => t2 => t3 => t4 => t5 => t6 => t7 => func(t1, t2, t3, t4, t5, t6, t7);
}
public static Func<T1, Func<T2, Func<T3, Func<T4, Func<T5, Func<T6, Func<T7, Func<T8, T9>>>>>>>> Carry<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this Func<T1, T2, T3, T4, T5, T6, T7, T8, T9> func)
{
return t1 => t2 => t3 => t4 => t5 => t6 => t7 => t8 => func(t1, t2, t3, t4, t5, t6, t7, t8);
}
public static Func<T1, Func<T2, Func<T3, Func<T4, Func<T5, Func<T6, Func<T7, Func<T8, Func<T9, T10>>>>>>>>> Carry<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> func)
{
return t1 => t2 => t3 => t4 => t5 => t6 => t7 => t8 => t9 => func(t1, t2, t3, t4, t5, t6, t7, t8, t9);
}
public static Func<T1, Func<T2, Func<T3, Func<T4, Func<T5, Func<T6, Func<T7, Func<T8, Func<T9, Func<T10, T11>>>>>>>>>> Carry<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> func)
{
return t1 => t2 => t3 => t4 => t5 => t6 => t7 => t8 => t9 => t10 => func(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10);
}
public static Func<T1, Func<T2, Func<T3, Func<T4, Func<T5, Func<T6, Func<T7, Func<T8, Func<T9, Func<T10, Func<T11, T12>>>>>>>>>>> Carry<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> func)
{
return t1 => t2 => t3 => t4 => t5 => t6 => t7 => t8 => t9 => t10 => t11 => func(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11);
}
public static Func<T1, Func<T2, Func<T3, Func<T4, Func<T5, Func<T6, Func<T7, Func<T8, Func<T9, Func<T10, Func<T11, Func<T12, T13>>>>>>>>>>>> Carry<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(this Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> func)
{
return t1 => t2 => t3 => t4 => t5 => t6 => t7 => t8 => t9 => t10 => t11 => t12 => func(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12);
}
public static Func<T1, Func<T2, Func<T3, Func<T4, Func<T5, Func<T6, Func<T7, Func<T8, Func<T9, Func<T10, Func<T11, Func<T12, Func<T13, T14>>>>>>>>>>>>> Carry<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(this Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> func)
{
return t1 => t2 => t3 => t4 => t5 => t6 => t7 => t8 => t9 => t10 => t11 => t12 => t13 => func(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13);
}
public static Func<T1, Func<T2, Func<T3, Func<T4, Func<T5, Func<T6, Func<T7, Func<T8, Func<T9, Func<T10, Func<T11, Func<T12, Func<T13, Func<T14, T15>>>>>>>>>>>>>> Carry<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(this Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> func)
{
return t1 => t2 => t3 => t4 => t5 => t6 => t7 => t8 => t9 => t10 => t11 => t12 => t13 => t14 => func(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14);
}
public static Func<T1, Func<T2, Func<T3, Func<T4, Func<T5, Func<T6, Func<T7, Func<T8, Func<T9, Func<T10, Func<T11, Func<T12, Func<T13, Func<T14, Func<T15, T16>>>>>>>>>>>>>>> Carry<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(this Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> func)
{
return t1 => t2 => t3 => t4 => t5 => t6 => t7 => t8 => t9 => t10 => t11 => t12 => t13 => t14 => t15 => func(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15);
}
public static Func<T1, Func<T2, Func<T3, Func<T4, Func<T5, Func<T6, Func<T7, Func<T8, Func<T9, Func<T10, Func<T11, Func<T12, Func<T13, Func<T14, Func<T15, Func<T16, T17>>>>>>>>>>>>>>>> Carry<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>(this Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> func)
{
return t1 => t2 => t3 => t4 => t5 => t6 => t7 => t8 => t9 => t10 => t11 => t12 => t13 => t14 => t15 => t16 => func(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16);
}
}
А что поделать то....
+141
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
//Перегруженый метод Paint
//Если нужно будет работать с графиксом в других методах (рисовать на нем в других методах)
//сделайте его глобальным
//Graphics gr = this.CreateGraphics();//Создаем объект графикс из окна
Graphics gr = e.Graphics;
int w = this.ClientSize.Width;//размеры клиентской области
int h = this.ClientSize.Height;//размеры клиентской области
int widthLines = 20;//Ширина клетки
int heightLines = 20;//Высота клетки
for(int i = 0; i < w; i += widthLines)
{
//Вертикальные линии
gr.DrawLine(new Pen(Brushes.Blue), new Point(i + widthLines, 0), new Point(i + widthLines, h));
//Горизонтальные линии
gr.DrawLine(new Pen(Brushes.Blue), new Point(0, i + heightLines), new Point(w, i + heightLines));
}
//Graphics gr = e.Graphics;
graf_func();
Pen p = new Pen(Color.Red, 3);// цвет линии и ширина
Point p1 = new Point(10, data_graf_x[0]);// первая точка
Point p2 = new Point(20, data_graf_x[1]);// вторая точка 1-y 2-x 1
Point p3 = new Point(30, data_graf_x[2]);// вторая точка 1-y 2-x 2
Point p4 = new Point(40, data_graf_x[3]);// вторая точка 1-y 2-x 3
Point p5 = new Point(50, data_graf_x[4]);// вторая точка 1-y 2-x
Point p6 = new Point(60, data_graf_x[5]);// вторая точка 1-y 2-x
Point p7 = new Point(70, data_graf_x[6]);// вторая точка 1-y 2-x
Point p8 = new Point(80, data_graf_x[7]);// вторая точка 1-y 2-x
Point p9 = new Point(90, data_graf_x[8]);// вторая точка 1-y 2-x
Point p10 = new Point(100, data_graf_x[9]);// вторая точка 1-y 2-x
Point p11 = new Point(110, data_graf_x[10]);// вторая точка 1-y 2-x
Point p12 = new Point(120, data_graf_x[11]);// вторая точка 1-y 2-x
Point p13 = new Point(130, data_graf_x[12]);// вторая точка 1-y 2-x
Point p14 = new Point(140, data_graf_x[13]);// вторая точка 1-y 2-x
Point p15 = new Point(150, data_graf_x[14]);// вторая точка 1-y 2-x
Point p16 = new Point(160, data_graf_x[15]);// вторая точка 1-y 2-x
Point p17 = new Point(170, data_graf_x[16]);// вторая точка 1-y 2-x
Point p18 = new Point(180, data_graf_x[17]);// вторая точка 1-y 2-x
Point p19 = new Point(190, data_graf_x[18]);// вторая точка 1-y 2-x
Point p20 = new Point(200, data_graf_x[19]);// вторая точка 1-y 2-x
Point p21 = new Point(210, data_graf_x[20]);// вторая точка 1-y 2-x
Point p22 = new Point(220, data_graf_x[21]);// первая точка
Point p23 = new Point(230, data_graf_x[22]);// вторая точка 1-y 2-x 1
Point p24 = new Point(240, data_graf_x[23]);// вторая точка 1-y 2-x 2
Point p25 = new Point(250, data_graf_x[24]);// вторая точка 1-y 2-x 3
Point p26 = new Point(260, data_graf_x[25]);// вторая точка 1-y 2-x
Point p27 = new Point(270, data_graf_x[26]);// вторая точка 1-y 2-x
Point p28 = new Point(280, data_graf_x[27]);// вторая точка 1-y 2-x
Point p29 = new Point(290, data_graf_x[28]);// вторая точка 1-y 2-x
Point p30 = new Point(300, data_graf_x[29]);// вторая точка 1-y 2-x
Point p31 = new Point(310, data_graf_x[30]);// вторая точка 1-y 2-x
//...
Point p180 = new Point(900, data_graf_y[89]);// вторая точка 1-y 2-x
Point[] my_point =
{
p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23,p24,p25,p26,p27,p28,p29,p30,
p31,p32,p33,p34,p35,p36,p37,p38,p39,p40,p41,p42,p43,p44,p45,p46,p47,p48,p49,p50,p51,p52,p53,p54,p55,p56,p57,p58,p59,p60,
p61,p62,p63,p64,p65,p66,p67,p68,p69,p70,p71,p72,p73,p74,p75,p76,p77,p78,p79,p80,p81,p82,p83,p84,p85,p86,p87,p88,p89,p90
};
Point[] my_point1 =
{
p91,p92,p93,p94,p95,p96,p97,p98,p99,p100,p101,p102,p103,p104,p105,p106,p107,p108,p109,p110,p111,p112,p113,p114,p115,p116,p117,p118,p119,p120,
p121,p122,p123,p124,p125,p126,p127,p128,p129,p130,p131,p132,p133, p134,p135,p136,p137,p138,p139,p140,p141,p142,p143,p144,p145,p146,p147,p148,p149,p150,
p151,p152,p153,p154,p155,p156,p157,p158,p159,p160,p161,p162,p163,p164,p165,p166,p167,p168,p169,p170,p171,p172,p173,p174,p175,p176,p177,p178,p179,p180
};
p180... мама дорогая... Боюсб даже представить, сколько временина это ушло, не говоря про ресурс клавиш ctlr, c и v.
При попытке добавить хотя бы 100 строк (из 200) пишет "Такой длинный код врядли может быть смешным. Пожалуйста, ограничьтесь сотней строк и 6000 символами."
Даже забавно
источник творения
http://www.cyberforum.ru/csharp-beginners/thread1069910.html
+137
public static string AddControlDigits(string input)
{
if (String.IsNullOrEmpty(input))
return "";
try
{
XDocument doc = XDocument.Parse(input.JavaSubString(input.IndexOf("<contracts>"), input.IndexOf("</contracts>") + "</contracts>".Length));
String s = new String(doc.ToString().ToCharArray());
XElement rootElement = doc.Root.Element("list_item");
string basicNumber = rootElement.Element("basicNumber").Value;
string endNumber = rootElement.Element("endNumber").Value;
string loanCaseNumber = rootElement.Element("loanCaseNumber").Value;
string loanCaseComplementNumber = rootElement.Element("loanCaseComplementNumber").Value;
string bridgeLoanComplementNumber = rootElement.Element("bridgeLoanComplementNumber").Value;
int checkNumber = CalcCheckDigitCU(basicNumber + endNumber);
int loanCaseCheckNumber = calcCheckDigitUP(loanCaseNumber);
int bridgeLoanCheckNumber = CalcCheckDigitCU(basicNumber + bridgeLoanComplementNumber);
rootElement.Add(new XElement("checkNumber", checkNumber));
rootElement.Add(new XElement("loanCaseCheckNumber", loanCaseCheckNumber));
rootElement.Add(new XElement("bridgeLoanCheckNumber", bridgeLoanCheckNumber));
input = input.Replace(s, doc.ToString());
return "";
}
catch (Exception ex)
{
throw;
}
}
жопа
+141
using System;
using System.Globalization;
using System.IO;
namespace CyberForumTasks
{
class Program
{
static void Main()
{
var text = File.ReadAllText("C:\\test.txt");
for (var i = 0; i < text.Length - 1; i++)
{
if (text[i].ToString(CultureInfo.InvariantCulture).Contains("1"))
if (text[i + 1].ToString(CultureInfo.InvariantCulture).Contains("0"))
if (text[i + 2].ToString(CultureInfo.InvariantCulture).Contains("1"))
Console.Write("101");
if (text[i].ToString(CultureInfo.InvariantCulture).Contains("1"))
if (text[i + 1].ToString(CultureInfo.InvariantCulture).Contains("1"))
if (text[i + 2].ToString(CultureInfo.InvariantCulture).Contains("0"))
Console.Write("110");
if (text[i].ToString(CultureInfo.InvariantCulture).Contains("1"))
if (text[i + 1].ToString(CultureInfo.InvariantCulture).Contains("1"))
if (text[i + 2].ToString(CultureInfo.InvariantCulture).Contains("1"))
Console.Write("111");
if (text[i].ToString(CultureInfo.InvariantCulture).Contains("1"))
if (text[i + 1].ToString(CultureInfo.InvariantCulture).Contains("0"))
if (text[i + 2].ToString(CultureInfo.InvariantCulture).Contains("0"))
if (text[i + 3].ToString(CultureInfo.InvariantCulture).Contains("0"))
Console.Write("1000");
if (text[i].ToString(CultureInfo.InvariantCulture).Contains("1"))
if (text[i + 1].ToString(CultureInfo.InvariantCulture).Contains("0"))
if (text[i + 2].ToString(CultureInfo.InvariantCulture).Contains("0"))
if (text[i + 3].ToString(CultureInfo.InvariantCulture).Contains("1"))
Console.Write("1001");
if (text[i].ToString(CultureInfo.InvariantCulture).Contains("1"))
if (text[i + 1].ToString(CultureInfo.InvariantCulture).Contains("0"))
if (text[i + 2].ToString(CultureInfo.InvariantCulture).Contains("1"))
if (text[i + 3].ToString(CultureInfo.InvariantCulture).Contains("0"))
Console.Write("1010");
}
}
}
}
Дан файл целых чисел. Продублировать в нем все числа, принадлежащие диапазону 5..10.