Fast String Comparison


D

Derek Hart

I need a fast way to compare strings. I have a custom designer where users
move around controls on screen, and the Microsoft property grid fills with
the properties when each control is selected, just like in Visual Studio.
After the grid is filled, I then run code to hide properties that I do not
want to be visible. I know I can do this before the grid is built, but that
will not work here. It has to happen after the grid is built.



I will have an array, or an xml file, or some type of way of storing
information such as Font.Bold or MaximumSize.Height, for example. I will
have about 1000 of these items. After the property grid is filled, I will
then loop through the grid, hiding properties that are in this list of 1000
items. Every property in the grid will be looped, and each time I need to
see if the property exists in the list of 1000 items. This is easy to do in
different ways, but I need a speedy way. Any ideas?



I could even store the 1000 items as one big string, and use IndexOf to see
if the string is there. Help...
 
Ad

Advertisements

B

BobRoyAce

Well, presumably, you have a list of properties that you want to hide.
Store those in a hashtable, or a collection. Then, cycle through all
the properties in your grid. If you find it in the hashtable/
collection, hide it; otherwise show it. In this way, you only cycle
through each item in the grid once.
 
Ad

Advertisements

C

Cor Ligthert[MVP]

Derek,

Your Grid is a user interface. The human eye cannot recognize a change in
0.05 second.
Therefore every computer is fast enough to do this even at the moment that
it is enterered in the grid.
(A kind of self made FindsSringExact method)

As you do not do it while entering then you can use that FindStringExact
metod in a loop.

You can do it with Linq distinc as well, but that will probably do it the
same.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top