In this particular case, IEquatable<Car> is not so much for your own use as for use by Framework collections. If all you will ever do is compare to Cars for equality in your own code, you could just write an equals method. You could even name it something like IsSameMakeAndMo del().
But the real point is that if you have a HashSet or other collection which guarantees that each item in the collection will be unique, that collection does...
User Profile
Collapse
-
That error comes from having a property with the same name as the Class to which it belongs.
The code you posted does not have any properties or fields, so you need to look more carefully at the error message to find which class, which file, which line it is referring to.Leave a comment:
-
You could distribute copies of the Access database (.mdb file) to each user, and use ADO.Net to connect to the file. There is no need to have Access installed on the client machines.
Bind to An ADO.Net Data Source
This is okay if the data is read-only. If it is read/write, then each database will be different than the others after users make updates.
A better solution is to use SQL Server Express which is free....Leave a comment:
-
You might need to post some code, but your first parameter to GroupBy is going to be a Func<yourObj, Key>, so instead of trying create a new object with a new property, why don't you encapsulate the concatenation logic into the key selector.
In other words (psuedocode)
...Code:string GetKey(Foo myComplex(obj)){ string key = new StringBuilder(); if(obj.contains(dataPointX)) key.Append(dataPointX.ToString());Leave a comment:
-
In order to marshal the thread back to the UI thread, it is the control which needs to call invoke on the delegate. This is different than just creating a new delegate and calling invoke on it, because, as tlhintoq says, that just keeps calling itself, and since the thread has not been marshalled yet, the InvokeRequired condition remains true.
Try the following:
...Code:delegate void LoadList(); private
Leave a comment:
-
Couple of things:
1. The Log4Net API explicitly says that the FileAppender is NOT safe for multithreaded applications (which just means it does not come out of the box with thread safety...you can still build thread safety around it, as you are doing).
2. The MinimalLock configuration basically says: "for any write operation, acquire the lock to the underlying stream, write, release the lock." This means that two threads...Leave a comment:
-
You proved that what I said is not entirely correct. How about if I just quote an expert...(sourc e Albahari - same link as above):...Leave a comment:
-
I think you are good. Let me explain why I think this works. Mind you, I am not an absolute expert or authority on the subject.
In your previous example, you were locking on the logger itself (Logging.log). Since this object owns the access to the log file, a lock on it basically locks out the file as well, no matter how access rights are configured initially.
So probably your second and third job come along, attempt to get...Leave a comment:
-
Not sure why. You might try removing your lock altogether just to see if it is your own lock that is causing the access denial. Does this error happen before even the first write, or is something being written to file, and this happens when a second process attempts to write?
Don't forget, locking just says: "you can't have access to this object until the lock is released." That does not mean the caller will wait for it to...Leave a comment:
-
Also, look into the Array.Sort<T>(T[], IComparer<T>) if all you want to do is sort a generic array with a specified direction.Leave a comment:
-
It should work fine. For an individual method, you would declare:
or for a class you would declare:Code:T[] MyFunction<T>(T[] Inputs, bool bOrder){...}
Code:class MyClass<T>{ T[] MyFunction(T[] Inputs, bool bOrder){..} }Leave a comment:
-
At the heart of the problem, no matter what logging API you use, is the fact that a single text stream is being accessed by more than one thread.
Locking is a good start, but remembermeans that any entering the "do logging" block will only proceed when the previous block is completely finished. Effectively, you will block logging threads one at a time, undermining the purpose of multi-threading.Code:lock(someLocker){do logging}
...Leave a comment:
-
BackgroundWorke r is the correct approach, but you cannot modify the ListView except from the RunWorkerComple ted event. If you modify the ListView inside your background thread, you will receive the cross-thread error.
If you search the forum for BackgroundWorke r, you will see several examples and explanations. Here is a recent post with the same issues:
http://bytes.com/topic/c-sharp/answe...-worker-thread...Leave a comment:
-
Do you have a SMTP service installed and running as a Windows Service on the same machine defined as "localhost" ?Leave a comment:
-
Small syntax note:
Code:List<Object> someItems = new List<Object>();
Leave a comment:
-
Otherwise, to use BinaryFormatter as you are doing, you need to store each serialized object in its own stream and read the entire stream into the Deserializer to reconstitute the underlying Int32 object.
Serialization is a way to store an entire object as bits, and deserialization is a way to read those bits and reconstitute the object.
It is not just the value of the object stored as bits, which is your assumption when you navigate...Leave a comment:
-
I'm not sure if you chose BinaryFormatter because you thought you were writing data to a file in binary format, or for other reasons. I'm pretty sure the Serialize method will add metadata to the stream describing the object it is serializing - in this case a simple int, but an object that lives in an assembly nonetheless.
To confirm this, simply open the output file and see if it is longer than 8 bytes for the two ints.
I...Leave a comment:
-
Yes, but you will still have a small error even after you get the string length.
Since this is a learning assignment, you should try hard to figure it out by yourself - you will learn better that way.
Hint: C# arrays start at (and include) index '0';
Good luck.Leave a comment:
-
The ListBox displays a ListBox.ObjectC ollection, which is simply a collection of objects.
The ListView contains a ListViewItemCol lection which is a collection of ListViewItems.
A Dictionary has a collection of KeyValuePairs.
If you want the ListBox to somehow reflect the combination of the TextBox value and the ListView item, you might consider making the each ListBox item a KeyValuePair<st ring, ListViewItem>.Leave a comment:
-
The easiest way is
but that will not enforce the length of the array. To do so you would have to create a struct or class with some bounds checking.Code:List<uint[]> ListOfSets = new List<uint[]>;
...Code:class SetClass { uint[] set = new uint[4]; public SetClass() { } public uint[] Set { get { if (this.set == null) this.set = new uint[4];Leave a comment:
No activity results to display
Show More
Leave a comment: