20100224

ToString() or not ToString()?

    public string GetDates(DateTime ArrivalDate)
    {
        DateTime ardate = Convert.ToDateTime(ArrivalDate.ToString());
        string arrivaldate = ardate.ToShortDateString().ToString();
        return arrivaldate;
    }

For greenhorns ('cause I got a few complains like „what the f__k are you talking about on those pages” :), the story goes like this:

Click on "next blog"!



:)

20100217

To be sure. (Ep. 2 - The strings)

You never know what may be hiding behind an innocent string...

if (body.Length> 17)
{
    try
    {
        output +=  body.Substring(0, 18) + "...";
    }
    catch (Exception ex)
    {
        output +=  body;
    }
}

"To be sure"

WARNING: Every new object must be cleaned! (You have no idea who used it before :))

        DataTable dtPackages = new DataTable();
        if (dtPackages.Rows.Count > 0 || dtPackages.Columns.Count > 0)
        {
            dtPackages.Clear();
            dtPackages.Columns.Clear();
            dtPackages.Rows.Clear();
        }

20100210

Second

Given this simple (working!) algorithm, please answer the next simple question:
What’s the number of rooms?
:)

if (RoomCount > 0)
{
    lblrooms.Text += dtGetRoomType.Rows[0]["Title"].ToString();
    for (int i = 0; i < RoomCount - 1; i++)
    {
        //int RoomCount = dtGetRoomType.Rows.Count;
        //lblrooms.Text += dtGetRoomType.Rows[i]["Title"].ToString();
        for (i = 0; i < RoomCount - 1; i++)
        {
            if (i > 0)
                lblrooms.Text += dtGetRoomType.Rows[i]["Title"].ToString();
            lblrooms.Text += " or ";
        }
        lblrooms.Text += dtGetRoomType.Rows[RoomCount - 1]["Title"].ToString();
    }
}

20100209

The First Entry!

    public class Item
    {
        string _name;
        ArrayList _subItems = new ArrayList();

        public Item(string name) { _name = name; }
        public string Name { get { return _name; } }
        public string Destination{ get { return _name; } }
        public ArrayList SubItems { get { return _subItems; } }
    }

...and they are surprised I’m calling them names.

20100204

Serialul "hai sa programam" are acum un nou format!

Numai de-as gasi mesajele cu perlele din vremea UBI... :)
Oricum, ce gasesc (sau produc - auch!) o sa postez aici. Sper sa ma ajute si corectorii de la Commoncensus, precum si vechii prieteni de suferinta.


The "Let's Go Programming" e-mailing series has a new format. If only I could find the hilarious pieces of code from the good old days when I used to work at UBI Soft / Gameloft, to have some archive to begin with...

Anyway, I will post here any funny piece of code I will find through the code I'm working on (or any dummy piece I will produce - ouch!). I hope my "checkers" from Commoncensus to help me ;), as well as the old suffering group from Ubi.