- 1
- 2
- 3
- 4
- 5
- 6
public void UpdateSession()
{
this.RequestTypeId = this.RequestTypeId;
this.ServiceId = this.ServiceId;
this.Name = this.Name;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+129
public void UpdateSession()
{
this.RequestTypeId = this.RequestTypeId;
this.ServiceId = this.ServiceId;
this.Name = this.Name;
}
"Обновление" сессии. Взято из реального проекта.
+113
public bool Read_XMl_File (XDocument Xml_Document, ref game_data Game_Data) {
bool Is_Success=false; /* Captures this function's result */
try {
this.Xml_Data = (game_data)Game_Data;
/* Recursively read through entire XML Document */
Xml_Document.Root.RecursivelyProcess (
Process_Child_Element,
Process_Parent_Element_Open,
Process_Parent_Element_Close);
Is_Success = true;
}
catch (Exception ex) { throw ex; }
Game_Data = this.Xml_Data; /* Pass the data back to Xml_Data */
return Is_Success;
}
public static void RecursivelyProcess (
this XElement element,
Action<XElement, int> childAction,
Action<XElement, int> parentOpenAction,
Action<XElement, int> parentCloseAction) {
if (element == null) { throw new ArgumentNullException ("element"); }
element.RecursivelyProcess (0, childAction, parentOpenAction, parentCloseAction);
}
private static void RecursivelyProcess (
this XElement element,
int depth,
Action<XElement, int> childAction,
Action<XElement, int> parentOpenAction,
Action<XElement, int> parentCloseAction) {
if (element == null) { throw new ArgumentNullException ("element"); }
if (!element.HasElements) { /* Reached the deepest child */
if (childAction != null) { childAction (element, depth); }
}
else { /* element has children */
if (parentOpenAction != null) { parentOpenAction (element, depth); }
depth++;
foreach (XElement child in element.Elements ()) {
child.RecursivelyProcess ( depth, childAction, parentOpenAction, parentCloseAction );
}
depth--;
if (parentCloseAction != null) { parentCloseAction (element, depth); }
}
}
}
+118
private void Gamexxx_Bolls_KeyDown(object sender, KeyEventArgs e)
{
OTCTeleText ttText;
List TTList;
TTList = new List();
if (e.KeyValue == 13)
{
try
{
//Control ctrl = (Control)sender;
ctrl = (Control)sender;
String szName = ctrl.Name.Substring(16);
int nOrderNumber = Convert.ToInt32(szName);
int nNumber = 0;
try
{
nNumber = Convert.ToInt32(ctrl.Text);
}
catch (Exception /*ex*/)
{
}
.......
}
catch (Exception /*ex*/)
{
}
}
}
Ярое использование трайкетча и чрезмерное внимание к женщинам лёгкого поведения ведут к освенциму.
TryParse вместо тысячи слов
Да, аве мне, аве!
+121
if (lvwUsers.SelectedItems[0].SubItems[1].Text != "" ||
lvwUsers.SelectedItems[0].SubItems[1].Text != string.Empty)
{
SecuritySettings.AuthenticationProtocol = ....
+120
public void PauseCheck(int x)
{
for (int i = 0; i < (x / 10); i++)
{
Thread.Sleep(10);
}
}
+108
using(FileStream fs = new FileStream("имя файла", FileMode.CreateNew))
{
using(StreamWriter sw = new StreamWriter(fs))
{
sw.Write("Lloyd ");
sw.Write("is ");
sw.Write("cool ");
sw.Write("guy. ");
sw.Write(":)");
sw.Flush();
}
}
Взято здесь http://www.rsdn.ru/forum/dotnet/394039.flat.aspx
Я не очень часто пишу на C#, но насколько я знаю, использование конструкции using предполагает, автоматическое очищение буфферов в конце блока кода.
+124
private void TextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Space)
{
TextBox box = sender as TextBox;
int start = box.SelectionStart;
int length = box.SelectionLength;
if (length == 0)
{
box.Text = box.Text.Insert(start + length, " ");
box.SelectionStart = start + 1;
}
else
{
string str1 = box.Text.Substring(0, start);
string str2 = box.Text.Substring(start + length);
box.Text = str1 + " " + str2;
box.SelectionStart = start + 1;
}
e.Handled = true;
}
}
Отборный говнокод выращенный на территории Индии.
Видимо им зарплату действительно за строчки кода платят.
+146
try
{
File.Delete(generatedFile);
}
catch { }
И такое бывает...
+119
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics p=e.Graphics;
p.DrawRectangle(Pens.Black, 100, 100, 120, 120);
p.DrawLine(Pens.Black, 100, 100, 150, 80);
p.DrawLine(Pens.Black, 220, 100, 270, 80);
p.DrawLine(Pens.Black, 270, 80, 150, 80);
p.DrawLine(Pens.Black, 220, 220, 270, 190);
p.DrawLine(Pens.Black, 270, 190, 270, 80);
p.DrawLine(Pens.Black, 140, 100, 140, 220);//Вертикальные линнии
p.FillRectangle(Brushes.Beige, 101, 101, 39, 39);
p.FillRectangle(Brushes.Brown, 101, 141, 39, 39);
p.FillRectangle(Brushes.DarkBlue, 101, 181, 39, 39);
p.FillRectangle(Brushes.ForestGreen, 141, 101, 39, 39);
p.FillRectangle(Brushes.LightGreen, 181, 101, 39, 39);
p.FillRectangle(Brushes.MediumTurquoise, 141, 141, 39, 39);
p.FillRectangle(Brushes.OrangeRed, 181, 181, 39, 39);
p.FillRectangle(Brushes.Orchid, 141, 181, 39, 39);
p.FillRectangle(Brushes.Plum, 181, 141, 39, 39);
p.DrawLine(Pens.Black, 180, 100, 180, 220);//Вертикальные линнии
p.DrawLine(Pens.Black, 100, 140, 220, 140);// Горихонтальные линнии
p.DrawLine(Pens.Black, 100, 180, 220, 180);// Горихонтальные линнии
p.DrawLine(Pens.Black, 140, 100, 190, 80);
p.DrawLine(Pens.Black, 180, 100, 230, 80);
p.DrawLine(Pens.Black, 220, 140, 270, 115);
p.DrawLine(Pens.Black, 220, 180, 270, 155);
p.DrawLine(Pens.Black, 121, 92, 239, 92);
p.DrawLine(Pens.Black, 137, 86, 253, 86);
p.DrawLine(Pens.Black, 239, 92, 239, 209);
p.DrawLine(Pens.Black, 253, 86, 253, 200);
}
Рисуем одну грань кубика Рубика.
http://www.cyberforum.ru/csharp-beginners/thread281606.html
+120
(class|struct|union)[\s\r\n(\w+)]*?(\w*)[\s\r\n]*?(:[\s\r\n(virtual)]*?\w+[\s\r\n]*?\w+(<\s*\w*\s*>)?([\s\r\n]*?,[\s\r\n(virtual)]*?\w+[\s\r\n]*?\w+(<\s*\w*\s*>)?)*?)?[\s\r\n]*?{[^{}]*(((?'open'{)[^{}]*)+((?'close-open'})[^{}]*)+)*(?(Open)(?!))[^{}]*}\s*?;
Выделение из исходников именованных с++ классов. Глаза боятся, но вроде работает.