#62 C# +301
protected Int32 Sum(int one, int two)
{
    int result;
    int tmp;
    
    tmp = one + two;
    result = tmp;
    return result;
}

Jesus.

By Anonymous, 2016-05-29 17:19:14
public bool IsTrue(bool value) {
    return value.ToString().length() == 4;
}
By Anonymous, 2018-04-04 15:46:36
string str = Console.ReadLine();
string len = 0;
for(int i = 0; i < str.Length; i++)
{
    len++;
}

Let's get string length :| Dummy

By Manoochehr Mojgani, 2017-12-13 16:47:11

return IsActive == true ? true : false;
By Anonymous, 2018-09-12 18:01:20
string random = "1";
By Anonymous, 2018-01-11 20:23:55
//this is a commit!!
trans.Commit();

It doesn't look like it was there because of some changes - someone simply wanted to be double sure he will see the commit there, I guess..

By Vukko, 2016-10-03 15:20:49
bool b = connection.isConnected() == true ? true : false;

My first internship presented me with this.

By Anonymous, 2017-12-12 09:39:54
protected void EnableEditButtons(bool Value)
{
    if (Value == false)
    {
        buttonAdd.Disabled = true;
        buttonDelete.Disabled = true;
    }
    else
    {
        buttonAdd.Disabled = false;
        buttonDelete.Disabled = false;
    }
}

// ...

if (IsEditable(ID))
    EnableEditButtons(true);
else
    EnableEditButtons(false);

I found this old code in an app I was updating for a client a number of years back. It was so good I documented it on my own blog.

By Jon Hartmann, 2017-12-12 17:09:54
public enum YesNoEnum
{
	Yes = 0,
	No = 1
}

I also like how they defined the enum values.

By Anonymous, 2018-05-19 19:33:44
if(products.Length < 0) {
    foreach (var p in products)
    {
        //...
    }
}
By Anonymous, 2021-07-24 20:56:07
public static bool HasValues<T>(this ICollection<T> collection)
{
    if (collection == null)
    {
        return false;
    }
    if (collection.Count == 0)
    {
        return false;
    }
    return true;
}
By oskarnrk, 2017-12-12 16:49:43
Console.WriteLine("|"+ Espace(x-1) + (h==3?" o":""));
Console.WriteLine("|"+ Espace(x-1) + (h==2?" o":(h==3?"/|\\":"")));
Console.WriteLine("|"+ Espace(x-1) + (h==1?" o":(h==2?"/|\\":(h==3?" |":""))));
Console.WriteLine("|"+ Espace(x-1) + (h==0?" o":(h==1?"/|\\":(h==2?" |":(h==3?"/ \\":"")))));
Console.WriteLine("|"+ Espace(x-1) + (h==0?"/|\\":(h==1?" |":(h==2?"/ \\":""))));
Console.WriteLine("|"+ Espace(x-1) + (h==0?" |":(h==1?"/ \\":"")));
Console.WriteLine("|"+ Espace(x-1) + (h==0?"/ \\" : ""));
By Caribou décoiffé, 2018-04-29 20:27:53
public void Method1(Enum foo)
{
    if (GetCondition1(foo))
    {
        doSomething();
    }
}

private bool GetCondition1(Enum foo)
{
    if (foo == Enum.Value1)
        return true;

    return false;
}
By Anonymous, 2018-02-23 17:34:55
public void Handle(SomethingCreatedEvent e)
{
    if (e.ActCode == "SOME_VALUE")
    {
        return;
    }
    else
    {
        // insert real function body here
    }
}
By Anonymous, 2017-12-20 15:40:49
var doc = (Parent as Doc);
doc.Name = (doc != null) ? "" : doc.Name
By MSx, 2020-01-16 12:39:39