- 1
- 2
- 3
- 4
- 5
- 6
- 7
/// <summary>
/// Converts an object to null. Returns null.
/// </summary>
public static object ToNull(this object value)
{
return null;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 16
−1
/// <summary>
/// Converts an object to null. Returns null.
/// </summary>
public static object ToNull(this object value)
{
return null;
}
Индийский extension
+1
Dictionary<Tuple<MapOfRestoredOwnership, bool, bool, bool>, IDictionary<PropertySqlGeography, IEnumerable<LandConsolidationData>>> villages
Parameter for function...
+120
// LockDepth IS enum type!
if(LockDepth == DepthType.Infinity)
_depthElement.InnerText = this.__lockDepth.ToString();
else
_depthElement.InnerText = (string) System.Enum.Parse(LockDepth.GetType(), LockDepth.ToString(), true);
I got exception on line 5. The LockDepth is enum :)
+124
/// <summary>
/// Return "Yes" for true and "No" for false
/// </summary>
public static string GetYesNoString(this bool val)
{
return val ? "Yes" : "No";
}
/// <summary>
/// Return "N/A" if no value, "Yes" for true and "No" for false
/// </summary>
public static string GetYesNoString(this object val)
{
if(val is bool)
return ((bool)val).GetYesNoString();
return "N/A";
}
Extension of the object class :) Very stupid because it make sense only for bool type, but it can be selected for every type in intellisense :)
+118.2
private ArrayList SortListings(ArrayList _listings)
{
ArrayList result = new ArrayList();
ArrayList company_names = new ArrayList();
Hashtable entities = new Hashtable();
foreach (ListOfListings l in _listings)
{
try
{
entities.Add(l.ListingName, l);
company_names.Add(l.ListingName);
}
catch
{
}
}
company_names.Sort();
for (int i = 0; i < company_names.Count; i++)
{
result.Add(entities[company_names[i]]);
}
return result;
}
Сортировка :)
+99.4
string date_format = DateTime.Now.ToString("dddd dd") + "th " + DateTime.Now.ToString("MMMM yyyy");
if (DateTime.Now.Day == 1 || DateTime.Now.Day == 21 || DateTime.Now.Day == 31) date_format = DateTime.Now.ToString("dddd dd")+"st "+DateTime.Now.ToString("MMMM yyyy");
else if (DateTime.Now.Day == 2 || DateTime.Now.Day == 22) date_format = DateTime.Now.ToString("dddd dd")+"nd "+DateTime.Now.ToString("MMMM yyyy");
else if (DateTime.Now.Day == 3 || DateTime.Now.Day == 23) date_format = DateTime.Now.ToString("dddd dd")+"rd "+DateTime.Now.ToString("MMMM yyyy");
DateTime formatting - don't try this at home!
−854.3
-- I found table with 20 millions rows, that nobody read just add new rows again and again :(
-- table size was 1 GB.
Я описал в коде.
+123.7
Request.QueryString["outer_email"] = null;
Это я намерил на несколько места :)
+130.5
try
{
// some logic
}
catch(Exception ex)
{
throw;
}
Error handling :)
+139
// export in csv - part of the code
// ...
foreach (users_view _item in _users_view)
{
_writer.Write(String.Format("{1}{0}{2}{0}{3}{0}{4}{0}{5}{0}{6}{0}{7}{0}{8}{0}{9}{0}{10}{0}{11}{0}{12}{0}{13}{0}{14}{0}{15}{0}{16}{0}{17}{0}{18}{0}{19}{0}{20}{0}{21}{0}{22}{0}{23}{0}{24}\n",
AppSettingsReader.GetValue("CSVFileSeparator"),
@"""" + _item.title_name + @"""", @"""" + _item.first_name + @"""",
@"""" + _item.last_name + @"""", @"""" + _item.job_title + @"""",
@"""" + _item.user_type_name + @"""",
@""""+_item.company_name+@"""",
(_item.telephone != null) ? (@"""" + _item.telephone + @"""") : (""),
(_item.fax != null) ? (@"""" + _item.fax + @"""") : (""),
@"""" + _item.email + @"""",
(_item.account_email != null) ? (@"""" + _item.account_email + @"""") : (""),
@"""" + _item.site_address + @"""",
@"""" + _item.advertisement_source_name+@"""",
@"""" + _item.address_1+@"""",
(_item.address_2 != null) ? (@"""" + _item.address_2+@"""") : (""),
@"""" + _item.country_name+@"""",
//_item.email_format_name,
(_item.postcode != null) ? (@"""" + _item.postcode+@"""") : (""),
(_item.county != null) ? (@"""" + _item.county+@"""") : (""),
@"""" + _item.town + @"""",
// (_item.is_active == false) ? ("No") : ("Yes"),
@"""" + _item.username+@"""",
@"""" + _item.password+@"""",
@"""" + _item.account_type_name + @"""",
@"""" + _item.creation_date + @"""",
(_item.is_newsletter_subscriber == false) ? ("No") : ("Yes"),
(_item.is_marketing_subscriber == false) ? ("No") : ("Yes")
)
);
}
Вот что нашел :)