I'd rather think the code stayed incomplete for some reason.
When overriding the Add() method of the collection (which he hasn't done yet), he could e.g. check that the item to be added has the correct value in its MyUpdateFields property and otherwise throw an exception.
Of course, Generics are a better way to solve it, but they were not available in e.g. .Net 1.1. And since the application was originally written in PHP, some odd ways of doing things might have their origin there.
Why even bother to try and figure out what this little-code-monster is, when you can get busy, and write better code
Because I'm in a testing phase right now and can't write additional code until that's done. The best I can do at the moment is try to understand what's here already. That is pretty important when taking over maintenance of undocumented apps.
I have an application that frequently uses the general List object with an bitmap type". I have two questions concerning these.
1: What is the best way to copy the bitmaps from one list to another while ensuring the Bitmaps in the original list are unchanged if changes are made to the new list. Currently i'm doing it in a forloop such as:
List<Bitmap> aviList1 = new List<Bitmap>(); aviList1.Clear();
for (int i=0; I originalList.Count; i++)
2: Is calling originalList.Clear sufficient to free up the memory or would it be necessary to loop through the list and dispose of the Bitmaps individually?
Thanks in advance for the always great support here at CodeProject.
Bitmaps are a scarce resource: they implement IDisposable, so you should clean up behind you, and Dispose all bitmaps you create. If you don't you may well get "Out of Memory" problems long before the actual RAM is exhausted. Additionally, depending on how you initially constructed the bitmaps, you may leave files or streams in use until the bitmap.Dispose method is called by your code, or by the garbage collector.
You need to construct a new image for each that you add to the other list, if you want the original unmodified when the aviList1[index] bitmap is changed.
However, it would look tidier with a foreach loop:
foreach (Bitmap b in originalList)
Or you could do it with Linq:
aviList.AddRange(originalList.Select(bm => new Bitmap(bm)));
(But that just hides the loop)
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
I am inferring from your answer (upvoted), that, in this case, it would be best for the OP to loop through his List<bitmap> and specifically dispose of them: that he should not rely on just clearing the List<bitmap>: is that correct ?
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
Sorry chaps, I couldn't find an appropriate forum so I'll take a chance I won't get flamed for using this one. I have a regex question. Given an input string like this:
Some text containing % complete and not much else
If I use a regex of \bcomplete\b I can find the whole word complete just fine. What I want to do is find % complete. I've tried \b% complete\b and \b\% complete\b and \b\x25 complete\b and other variations I can think of but I can never get it to select % complete. Does anyone know if it's possible to do it and how? I can find nothing anywhere that says % cannot participate in an expression.
I've tried two different apps, such as RegexBuilder and RegexBuddy but I can't get it working in either. Does anyone have any ideas? Thanks.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
private void CheckChildNode(TreeNode currNode)
//set the children check status to the same as the current node
bool checkStatus = currNode.Checked;
foreach (TreeNode node in currNode.Nodes)
node.Checked = checkStatus;
private void CheckParentNode(TreeNode currNode)
TreeNode parentNode = currNode.Parent;
if (parentNode == null)
parentNode.Checked = true;
foreach (TreeNode node in parentNode.Nodes)
parentNode.Checked = false;
break; // TODO: might not be correct. Was : Exit For
Folks I had asked this question a couple of days ago and based on the response i have attempted to implement it, I posted a reply in the thread but it did not bump the topic so i'm just bumping here to see what the opinion of the experts here are:
So basically before i carry on with my design I am wondering from an OO point of view if I am approaching this task in the right way or if what I am doing is overkill and could be greatly simplified?
There is no clear and specific "right way" in OO; it's called OO once you structure your methods and data into objects.
If you think the new code is more easily to maintain than the original code, than it'd be an improvement. If the new code looks "complex" or contains a lot of repetitions, then it'd be wise to re-evaluate the design.
Is it an improvement (from your viewpoint), in terms of readability?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]