I'm reviewing some code from one of our contractors:
if (userLists != null)
{
Int32 numberOfItems = userLists.Count;
if ((numberOfItems & 1) == 1)
{
var emptyList = new tblList();
userLists.Add(emptyList);
}
}
Now, I'm trying to understand this, so, can someone please confirm with me if I have got this right or not?
- Do we have an instance of a userList?
- Yes. Get a the number of items in the userLists object.
- if (the number of items equals 1 (Yes/true) AND 1 equals 1 (yes/True) ) AND that result equals 1 (Yes/True), then add an empty list object to the list.
- Else: nothing.
If so (W.T.FFFFFFFFFFFFFFFFFFFF !!!!!!!!!!), that can be refactored to
if (numberOfItems == 1)
{
..
}
but even that's crap because I don't want a list with 'empty' items.
So did I read that piece of code correctly?
Oh, one more sigh at the use of Int32
vs Int
:( (but I digress).