|
Thats just like doing a if(!list.contains(myobject)) { list.add(myobject); } just in a nice package and it also only solves the adding, not the removing which imo is the biggest problem because all the times the list have to be looped through starts to grow exponentially...
|
|
|
|
|
0) You gave us precious little info to work with here
1) You wanted a method to do it, I gave you one. Since I didn't know what you were working with (there was no real indication that you're working with intrinsic types), I couldn't recommend using a hash set. In fact, you talked about binding in a grid, so I presumed a complex object.
2) I suppose you could use Linq, but I'm not so sure that it would be any faster, and even if it was, I would still be prompted to do the list class override and pass the new list into it if for no other reason than to abstract the functionality out of the code that's using it, and into the code that should do it.
3) In the time we've been discussing it, you could have tried both ideas to see which one works best for you.
4) I wish the List object had a Merge method that allowed us to optionally omit non-unique objects.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
0 and 1) true, i'll try to explain a little better:
I have a base object that 4 other class inherit from, in the base object class there is a uinque guid(a ulong) that never will be different from object to object.
2) i've had a look at linq but i could only find a way to find equal objects
3) i already have a working solution but it's not fast enough, what it does is to put all the objects from the reading function into a new list, then a foreach that does a if(!oldList.contains(currentObject)) where i then add it, after that i do the same but with switched roles of the new and old list and add the guid of those to be removed to a new list because i can't modify a collection while enumerating and finally remove the objects from the oldList
and oh btw i the information my objects are read from another applications(well game) memory
Sorry if my previous post sounded rude because that wasn't my intention
|
|
|
|
|
Two options(for faster solutions):
1) you could use a dictionary<key, value> => extremely fast but you can only search(fast) based on the key. And some more memory required(for the keys)
2) Implement IComparable and use something like:
int idx = oldList.BinarySearch(currentObject);
if(idx<0)
|
|
|
|
|
actually i did use a dictionary but changed it to a list for various reasons, anyway i think i'll try to make a reverse for loop like this:
for(int i = GetLengthOfLongestList(); i>0; i--)
{
try
{
var currentNewObject=newList[i];
}
catch
{
}
and a
try
{
var currentOldObject=oldList[i];
}
catch
{
}
/after checks
oldList.removeAt(i);
oldList.add(currentNewObject);
}
}
modified on Wednesday, February 3, 2010 10:46 AM
|
|
|
|
|
Since .NET 3.5 we have a HashSet class that does that automatically. HashSet.Add[^]
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
But you can only compare intrinsic types. Is it really appropriate for complex objects where one or more properties could be required to be unique?
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
hello again
1) how can i tell a connection that you should connect to Specified sql instance (sql server 2005) in the local machine ?
thanks!!!!
|
|
|
|
|
In the connection string, you need to provide instance name. i.e. localhost\SQLExpress (where SQLExpress is your instance name).
Server=myServerName\theInstanceName;
Also refer to this.[^]
|
|
|
|
|
Hello, I have a grid with a description column and 4 date columns. How do I modify the background color of the datepicker that is associated with the date columns? I set the Styles.Editor.BackColor property but that only changes the background color of the actual calender that drops down.
Thanks,
Lindsay
|
|
|
|
|
hi all
i have developed an windows application and want to build a (setup project) for it !
but there is some problem !
1) how can i find if there is another version of this application
2) warn user to repair or uninstall after installing new version! (like most of other software s)
3) find if there is any sqlserver2005 instances run on the services.msc if there is an instance but is not run!, then run it (without need the user to run this services manually)
please note me any thing in your mind about any of above sections!
thanks in advance
|
|
|
|
|
Hey my frnds .... I was working on a Dial-up networking for my customers ... which accepts connection from another PC by just dialing (only a modem and a phone line is needed in both PCs) which is not the concern of C# in my case .... But if I didnt not hide this connection from network connections in windows , another persons(may b professionals) can change things and might mess up my work .... So what i wanted here is that ... I want to write a C# code which will hide the connection i created and allows the user to run the connection @ any time with the help of C# code .... is that possible ... if yes please help me
Thank you
|
|
|
|
|
Sounds user hostile. A user has the right to be able to screw up his system any time he likes.
|
|
|
|
|
Thank you for your response
i know that my friend ... but my problem is not the users ... it is easy the users to tell that not to do any thing on it ... but if other professional come ...they may mess it up just to ruin my business ... any ways ... if it is not clear what i wanted is ... is it possible to write a code which will hide the connection from being viewed by the users and also to run it using C# code ??? .... if it is possible even other persons cant find it ..
|
|
|
|
|
Hi all,
I am making an application comprising both C/C++ and .Net environments (for different modules). Both C++ and .Net modules create logs in some XML files. But I am now facing many problems in maintaining all the log files (mostly because of their sizes).
I am planning to create my logs in some database. But I am not familiar with using any database with C++ or with .Net code. Here are my requirements:
1 The very first requirement is that database should be free to use.
2 database should be able to connect with both C++ module and .Net (C# module)
Can anybody suggest me any such database that can be used freely. Also help me in knowing some tutorial by which I can connect my application with that free database.
Thanks in Advance
Aseem
|
|
|
|
|
1. - Microsoft SQL-Server Express is for free, but you can't use databases with a size over 4gb.
- There also exists a free database version from IBM DB2.
- At least you could look for an oracle version (I thought there is also a free version, but I'm not sure).
[Edit:]You could also use a MySQL database. But its not my favorite![/edit]
2. You should be able to connect to all named databases above!
Greetings
Covean
|
|
|
|
|
|
Free stuff is often not worth the price.
I wouldn't use a database as a log file. For one thing, how does the application log a message saying it can't access the database? A logging system should be as simple as possible, with the fewest points of failure you can achieve.
I tend to use SQL Server Express for the little applications I write. A customer can then upgrade to full-blown SQL Server if they choose.
|
|
|
|
|
Dito.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
For something like log files, you don't really need a full-blown database.
If you just want a database to make working with large files easier, I suggest you take a look at SQLite[^] (.NET wrapper[^]). It is not a database server, but a library that runs directly in your process.
It's ideal for client-side databases where you don't want to deal with deploying a database server; it's just another .dll to be copied with your app.
|
|
|
|
|
I want to hide/show a particular row of my tablelayoutpanel by the click of a button. I dnt want to remove and add the row again,i jst want to simply show/hide....
Can smebody help me with the code....????
Thanks in advance....
|
|
|
|
|
Using JQuery[^] its as simple as this
function ButtonClick()<br />
{<br />
$("element_id").hide();<br />
}
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
There is no facility to do this in the TableLayoutPanel methods and properties. You cannot make rows visible or hidden. You'd have to fake this using some other method.
Off the top of my head, you could move the section you want to a seperate TableLayoutPanel, which itself is put in a Panel control. You can make the Panel visible or hidden at will, taking its child controls with it. Or you could do it the other way and put your child controls in a Panel, then put the Panel in the TableLayoutPanel row. This method may not be feasible depending on your situation.
|
|
|
|
|
Use SizeType.Absolute with a value of 0F (for the RowStyle) to hide a particular row. For example, if you had 3 rows and wanted to alternately hide and show the middle row, you could use the following:
// Hide middle row.
this.tableLayoutPanel1.RowStyles[ 0 ] = new RowStyle( SizeType.Percent, 50f );
this.tableLayoutPanel1.RowStyles[ 1 ] = new RowStyle( SizeType.Absolute, 0F );
this.tableLayoutPanel1.RowStyles[ 2 ] = new RowStyle( SizeType.Percent, 50F );
// Show middle row.
this.tableLayoutPanel1.RowStyles[ 0 ] = new RowStyle( SizeType.Percent, 20f );
this.tableLayoutPanel1.RowStyles[ 1 ] = new RowStyle( SizeType.Percent, 20F );
this.tableLayoutPanel1.RowStyles[ 2 ] = new RowStyle( SizeType.Percent, 20F );
(Note that the "Percent" styles don't actually need to add to 100. The individual values are relative to the "total" of all the percents, so each row in the end winds up using 1/3 of the panel).
(Also, you should group the controls on the "hidden row" in some way so you can collectively disable them so they don't get focus when hidden via tabbing).
modified on Monday, February 1, 2010 6:26 PM
|
|
|
|
|
Hello
When I have a look at the Color and the Font property I use in my designer, the language in the two editors is a different one.
The FontDialog is displayed in German (i assume because of the operating system's language).
But the ColorDialog is displayed in English.
How can I change the ColorDialog's language to German as well?
I have searched here for articles about ColorEditors and found this one:
ColorEditorEx - An extension to the ColorEditor to support translucent colors[^]
On the screenshot the language is German, but when I open the application, its english again (the tabs).
I hope someone can tell me how it is possible to change the language of the ColorEditor to german
Windows language = german
Visual Studio = english (maybe thats the reason?)
Thanks for your help in advance
modified on Monday, February 1, 2010 9:38 AM
|
|
|
|