- 1
- 2
- 3
- 4
string s=textBox1.Text,d="";
if (s.lenght > 0)
for (int i = 0; i < s.lenght- 1; i++)
d += s[i];
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+118
string s=textBox1.Text,d="";
if (s.lenght > 0)
for (int i = 0; i < s.lenght- 1; i++)
d += s[i];
Код, присланный товарищем мне на проверку. Смех и грех - этот человек учится на третьем курсе политеха на специальности ИТ.
+128
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int x = Convert.ToInt32(comboBox1.Text);
switch (x)
{
case 2: textBox1.Visible=true;
textBox2.Visible = true;
textBox3.Visible = false;
textBox4.Visible = false;
textBox5.Visible = false;
textBox6.Visible = false;
textBox7.Visible = false;
textBox8.Visible = false;
textBox9.Visible = false;
textBox10.Visible = false;
break;
case 3:
textBox1.Visible = true;
textBox2.Visible = true;
textBox3.Visible = true;
textBox4.Visible = false;
textBox5.Visible = false;
textBox6.Visible = false;
textBox7.Visible = false;
textBox8.Visible = false;
textBox9.Visible = false;
textBox10.Visible = false;
break;
//и так до 10
//...
private void button1_Click(object sender, EventArgs e)
{
double p1 = 1 / Convert.ToDouble(textBox1.Text);
double p2 = 1 / Convert.ToDouble(textBox2.Text);
double p3 = 1 / Convert.ToDouble(textBox3.Text);
double p4 = 1 / Convert.ToDouble(textBox4.Text);
double p5 = 1 / Convert.ToDouble(textBox5.Text);
double p6 = 1 / Convert.ToDouble(textBox6.Text);
double p7 = 1 / Convert.ToDouble(textBox7.Text);
double p8 = 1 / Convert.ToDouble(textBox8.Text);
double p9 = 1 / Convert.ToDouble(textBox9.Text);
double p10 = 1 / Convert.ToDouble(textBox10.Text);
double inv;
int x = Convert.ToInt32(comboBox1.Text);
switch (x)
{
case 2:
inv=(1/p1+1/p2);
break;
case 3:
inv = ((1 / p1) + (1 / p2)+(1/p3));
break;
case 4:
inv = ((1 / p1) + (1 / p2) + (1 / p3)+(1/p4));
break;
case 5:
inv = ((1 / p1) + (1 / p2) + (1 / p3) + (1 / p4)+(1/p5));
break;
case 6:
inv = ((1 / p1) + (1 / p2) + (1 / p3) + (1 / p4) + (1 / p5)+(1/p6));
break;
case 7:
inv = ((1 / p1) + (1 / p2) + (1 / p3) + (1 / p4) + (1 / p5) + (1 / p6) + (1 / p7));
break;
case 8:
inv = ((1 / p1) + (1 / p2) + (1 / p3) + (1 / p4) + (1 / p5) + (1 / p6) + (1 / p7) + (1 / p8));
break;
case 9:
inv = ((1 / p1) + (1 / p2) + (1 / p3) + (1 / p4) + (1 / p5) + (1 / p6) + (1 / p7) + (1 / p8) + (1 / p9));
break;
case 10:
inv = ((1 / p1) + (1 / p2) + (1 / p3) + (1 / p4) + (1 / p5) + (1 / p6) + (1 / p7) + (1 / p8) + (1 / p9) + (1 / p10));
break;
double rez = 1 / inv;
textBox11.Text = Convert.ToString(rez);
}
}
+114
[Serializable()]
public class Vendor
{
#region Constructors
public Vendor(long vendorID)
{
LoadData(vendorID);
}
internal Vendor(Vendor argVendor)
{
if (argVendor != null)
{
this.ID = argVendor.ID;
this.VendorName = argVendor.VendorName;
this.Account = argVendor.VendorAccount;
this.EIN = argVendor.VendorEIN;
this.Address = argVendor.VendorAddress;
this.City = argVendor.VendorCity;
this.State = argVendor.VendorState;
this.PostalCode = argVendor.VendorZip;
this.Phone = argVendor.VendorPhone;
this.ContactName = argVendor.VendorContact;
this.VendorCode = argVendor.VendorCode;
this.Country = argVendor.VendorCountry;
this.FaxNumber = argVendor.VendorFax;
this.Email = argVendor.Email;
}
}
#endregion
public void LoadData(long vendorID)
{
POMRepositoryDataClassesDataContext db = new POMRepositoryDataClassesDataContext();
var ven = (from v in db.Vendors
where v.ID == vendorID
select v).SingleOrDefault();
if (ven != null)
{
populateMe(ven);
}
}
public void LoadDataByVendorCode(string argVendorCode)
{
POMRepositoryDataClassesDataContext db = new POMRepositoryDataClassesDataContext();
var ven = (from v in db.Vendors
where v.VendorCode == argVendorCode
select v).Take(1).SingleOrDefault();
if (ven != null)
{
populateMe(ven);
}
}
private void populateMe(Vendor ven)
{
this.ID = ven.ID;
this.VendorName = ven.VendorName;
this.Account = ven.VendorAccount;
this.EIN = ven.VendorEIN;
this.Address = ven.VendorAddress;
this.City = ven.VendorCity;
this.State = ven.VendorState;
this.PostalCode = ven.VendorZip;
this.Phone = ven.VendorPhone;
this.ContactName = ven.VendorContact;
this.VendorCode = ven.VendorCode;
this.Country = ven.VendorCountry;
this.FaxNumber = ven.VendorFax;
this.Email = ven.Email;
}
}
No comments!!!
+126
Type window = core.getTypeCreationWindowFromType( this.currentType );
if (window != null)
{
var cr_window = Activator.CreateInstance( window );
if (window == typeof( forms.showWindow ))
{
((forms.showWindow)cr_window).setTitle( "Добавить новую позицию" );
((forms.showWindow)cr_window).setType( this.chldrenType );
((forms.showWindow)cr_window).fill( );
((forms.showWindow)cr_window).setSelectionMode( );
if (this.isExlusivePositionResolve == true)
{
// var new_item = Activator.CreateInstance( this.chldrenType );
//new_item = (types.ICovertiablePersist<this.chldrenType>)core.instance().ge
((forms.showWindow)cr_window).selectedItem += ( forms.showWindow form ) =>
{
var new_item = Activator.CreateInstance( this.chldrenType );
///new_item = core.instance().getObject(this, form.selected_id);
int parent_object_id = -1; // Это номер связанного с
//выриьбаемым обектом объекта,
//тоесть если окно выбора было
//кастомизированна и тип выбираемы
//х щзначений другой нежели целевой
//то мы ищем звязь между обектом ородите и дитя !!!
FieldInfo[] fields = this.chldrenType.GetFields( );
int id = ((types.persistent)new_item).id;
bool isExists = false;
for (int i = 0; i < this.dgv_grid.RowCount; i++)
{
int id_s;
int.TryParse( this.dgv_grid.Rows[i].Cells["id"].Value.ToString( ),out id_s );
if (id_s == id)
{
int count;
int.TryParse( this.dgv_grid.Rows[i].Cells["count"].Value.ToString( ), out count );
this.dgv_grid.Rows[i].Cells["count"].Value = count++;
isExists = true;
}
}
if (isExists == false)
{
this.addOnePosition( new_item );
}
};
}
}
else
{
((Form)cr_window).FormClosed += ( object sender, FormClosedEventArgs e ) => {
this.fill( );
};
}
((System.Windows.Forms.Form)cr_window).Show( );
}
else
{
MessageBox.Show( "Объекты такого типа создавать запрещено" );
}
Нашел его миленкого. Переписываю ))) А коменн то комент
+140
try
{
client.SendData(xml);
}
catch(Exception e)
{
string s = e.ToString();
if(s.Substring(0,80)=="System.InvalidOperationException: Operation not allowed on non-connected sockets")
{
client.tcpclient.Close();
clients.Remove(client.SessionId);
}
else if (s.Substring(0,71)=="System.IO.IOException: Unable to write data to the transport connection")
{
client.tcpclient.Close();
clients.Remove(client.SessionId);
}
else
{
client.tcpclient.Close();
clients.Remove(client.SessionId);
}
}
нестандартное определение типа исключения
найдено в примерах кода кандидата на работу
+126
public class BasisTariffing : IFormattable
{
public override bool Equals(object obj) {
BasisTariffing subject = obj as BasisTariffing;
if (subject == null) {
return false;
}
return ((Profession == null && subject.Profession == null) || (Profession != null && subject.Profession != null && Profession.Equals(subject.Profession))) &&
((BasisRateOf == null && subject.BasisRateOf == null) || (BasisRateOf != null && subject.BasisRateOf != null && BasisRateOf.Equals(subject.BasisRateOf))) &&
((BasisRating1Main == null && subject.BasisRating1Main == null) || (BasisRating1Main != null && subject.BasisRating1Main != null && BasisRating1Main.Equals(subject.BasisRating1Main))) &&
((BasisRating1Add == null && subject.BasisRating1Add == null) || (BasisRating1Add != null && subject.BasisRating1Add != null && BasisRating1Add.Equals(subject.BasisRating1Add))) &&
((BasisRating2Main == null && subject.BasisRating2Main == null) || (BasisRating2Main != null && subject.BasisRating2Main != null && BasisRating2Main.Equals(subject.BasisRating2Main))) &&
((BasisRating2Add == null && subject.BasisRating2Add == null) || (BasisRating2Add != null && subject.BasisRating2Add != null && BasisRating2Add.Equals(subject.BasisRating2Add))) &&
((BasisRating3Main == null && subject.BasisRating3Main == null) || (BasisRating3Main != null && subject.BasisRating3Main != null && BasisRating3Main.Equals(subject.BasisRating3Main))) &&
((BasisRating3Add == null && subject.BasisRating3Add == null) || (BasisRating3Add != null && subject.BasisRating3Add != null && BasisRating3Add.Equals(subject.BasisRating3Add))) &&
((BasisRating4Main == null && subject.BasisRating4Main == null) || (BasisRating4Main != null && subject.BasisRating4Main != null && BasisRating4Main.Equals(subject.BasisRating4Main))) &&
((BasisRating4Add == null && subject.BasisRating4Add == null) || (BasisRating4Add != null && subject.BasisRating4Add != null && BasisRating4Add.Equals(subject.BasisRating4Add))) &&
((BasisRating5Main == null && subject.BasisRating5Main == null) || (BasisRating5Main != null && subject.BasisRating5Main != null && BasisRating5Main.Equals(subject.BasisRating5Main))) &&
((BasisRating5Add == null && subject.BasisRating5Add == null) || (BasisRating5Add != null && subject.BasisRating5Add != null && BasisRating5Add.Equals(subject.BasisRating5Add))) &&
((BasisRating6Main == null && subject.BasisRating6Main == null) || (BasisRating6Main != null && subject.BasisRating6Main != null && BasisRating6Main.Equals(subject.BasisRating6Main))) &&
((BasisRating6Add == null && subject.BasisRating6Add == null) || (BasisRating6Add != null && subject.BasisRating6Add != null && BasisRating6Add.Equals(subject.BasisRating6Add))) &&
((BasisRating7Main == null && subject.BasisRating7Main == null) || (BasisRating7Main != null && subject.BasisRating7Main != null && BasisRating7Main.Equals(subject.BasisRating7Main))) &&
((BasisRating7Add == null && subject.BasisRating7Add == null) || (BasisRating7Add != null && subject.BasisRating7Add != null && BasisRating7Add.Equals(subject.BasisRating7Add))) &&
((BasisRating8Main == null && subject.BasisRating8Main == null) || (BasisRating8Main != null && subject.BasisRating8Main != null && BasisRating8Main.Equals(subject.BasisRating8Main))) &&
((BasisRating8Add == null && subject.BasisRating8Add == null) || (BasisRating8Add != null && subject.BasisRating8Add != null && BasisRating8Add.Equals(subject.BasisRating8Add)));
}
public override int GetHashCode() {
return ((Profession != null) ? Profession.GetHashCode() : 0) ^
((BasisRateOf != null) ? BasisRateOf.GetHashCode() : 0) ^
((BasisRating1Main != null) ? BasisRating1Main.GetHashCode() : 0) ^
((BasisRating1Add != null) ? BasisRating1Add.GetHashCode() : 0) ^
((BasisRating2Main != null) ? BasisRating2Main.GetHashCode() : 0) ^
....................................
}
}
Как вам перегрузочка? И это только часть кода *сущности*, больше просто не вместилось =)
+123
if (!(IsPostBack == true))
// далее везде, см. ссылку
Реальный индус (Thoothukudi, Tamil Nadu, India) в реальном вопросе на StackOverflow (http://stackoverflow.com/questions/5295149/) наложил натуральную кучу говна.
+120
public class XXX
{
private Object m_ForLock = new object();
private String m_Path = "";
public XXX(String Path)
{
lock (m_ForLock)
{
m_Path = Path;
}
}
}
+120
string tmpS;
//идут всякие монипуляции с этой строкой
//. . .
tmpS.Remove(0, tmpS.Length);
Реальный код из коммерческого продукта.
+126
private const string constDefFeedLimitValue = "5";
private string feedLimit = constDefFeedLimitValue;
private int feedLmt;
protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
{
try
{
feedLmt = Convert.ToInt32(feedLimit);
}
catch (Exception)
{
feedLmt = 0;
}
...
}
Автор из Киева, имеет статус MVP.