collections

C# collection to Classic ASP [updated]

Hi, I am having trouble exposing a C# collection to Classic ASP. I've tried to use IEnumerable and Array. but I get the "object not a collection" error. my method looks like: public IEnumerable<MyObj> GetMyObj() { ... } and on the Classic ASP side: Dim obj, x Set obj = Server.CreateObject("Namespace.class") For Each x in obj.Get...

working with images as a database table column

Hi, Ii have a database (sql server 2008) and I am working with c# in visual studio 2010. I want to establish a connection with my db. I have written a code for that as follows: SqlConnection mySqlConnection = new SqlConnection ("Data Source=servername\\SQL2008; Initial Catalog=MyData;UID=MyID;PWD=mypassword;"); SqlCommand...

HashMap alternatives for memory-efficient data storage

I've currently got a spreadsheet type program that keeps its data in an ArrayList of HashMaps. You'll no doubt be shocked when I tell you that this hasn't proven ideal. The overhead seems to use 5x more memory than the data itself. This question asks about efficient collections libraries, and the answer was use Google Collections. My...

PropertyInfo.GetValue() how do I index collection by string using reflection in C#?

Hi Guys. Let's say I have a class, which has a NameValueCollection property. public class TestClass { public NameValueCollection Values { get; private set; } public TestClass() { Values = new NameValueCOllection(); Values.Add("key", "value"); Values.Add("key1", "value1"); } } I know how to get...

Getting Dictionary<K,V> from ConcurrentDictionary<K,V> in .NET 4.0

I'm parallelizing some back-end code and trying not to break interfaces. We have several methods that return Dictionary and internally, I'm using ConcurrentDictionary to perform Parallel operations on. What's the best way to return Dictionary from these? This feels almost too simple: return myConcurrentDictionary.ToDictionary(kvp => ...

Performance of Collection class in Java

All, I have been going through a lot of sites that post about the performance of various Collection classes for various actions i.e. adding an element, searching and deleting. But I also notice that all of them provide different environments in which the test was conducted i.e. O.S, memory, threads running etc. My question is, if there...

in F#, How do you merge 2 Collections.Map instances?

I am trying to merge two Maps, but there is no built in method for joining Collections. So how do you do it? ...

Java: Set interface and Collection interface differences

I just looked up the Set interface and found that it mostly (or completely) only redeclares functions which are already in the Collection interface. Set itself extends Collection, so doesn't that mean that the Set interface automatically has all the functions from Collection? So why are they redeclared then? For example, Set redeclares ...

How to get the key when a corresponding value is used instead?

I am using Android 2.1 SDK, the application reads from the Sqlite database, a table that has two columns, an id, and a string. I read in this into a HashMap<Long, String>, the value part of it gets displayed in a List, now, I wish to obtain the key value, so I cooked up this simple routine: private Map.Entry<Long, String> getEntry(Stri...

Remove overlapping items between two List<string> collections

I have two collections of List, let's call them allFieldNames (complete set) and excludedFieldNames (partial set). I need to derive a third List that gives me all non-excluded field names. In other words, the subset list of allFieldNames NOT found in excludedFieldNames. Here is my current code: public List<string> ListFieldNames(List<st...

How do I turn my custom linked list into an array?

I have to implement a method: E[] toArray(E[] a) // Pass an array, convert to singly linked list, then return the array. from java.util Interface List<E> As I mentioned, I have to pass an array, convert it to a singly linked list, sort it, then return the array. In the Node class I have this to work with: public Node(E v, Node<...

Building a collection of business categories in C# without a DB

This is a two part question really (at the end). Let's say I have a DB table of businesses. Each business has a category field, filled with a category "slug" (food-restaurant-brazilian for example). Instead of building a BusinessCategory DB table, I'm just going to build it in-code. Something like this: public class BizCategory { pub...

Collection vs ICollection

I have created a dummy projet for testing collection and ICollection.I have a user class and wanted to create a collection.Example - ICollection<User> users = new Collection<User>(); Collection<User> users = new Collection<User>(); Both code are working fine whether I use Collection or I collection.Now can anyone tell me what is diffe...

Iterating ConcurrentQueue<T>

Is this a safe way of iterating ConcurrentQueue<T>? while (cq.GetEnumerator().MoveNext()) { IIndexTask task; if (cq.TryDequeue(out task)) task.Execute(service); } ...

Tradeoff of creating collection on the fly or beforehand.

Whats the pro's and con's of creating a collection instance on the fly or beforehand, during initialisation for use later. I have a whole bundle of threads that each need to output a buffer which is enqueued on a priority or intervalheap queue. I was wondering if it would be more effecient in c# to create, a circular buffer of type X, ...

Is choosing proper collection type premature optimization ?

Hi, Recently I'm encountering this type of code ever more frequently: List<Something> list = new LinkedList<Something>(); // add a bunch of constants to the list // keep in mind that the number of items added is known on list creation return list.toArray(new Something[list.size()]); Now in my honest opinion this is improper use of th...

How can I debug the value of a PL/SQL collection in Oracle ?

I'm debugging a procedure which ... returns certain values. The procedure seems to use DBMS_SQL.DESCRIBE_COLUMNS2 which was, till now unknown to me. One of the out variables of the DBMS_SQL.DESCRIBE_COLUMNS2 procedure is a collection, and I want to examine that value is being returned into that - how can I observe/watch/examine this va...

Multiple key lookup for Dictionary

I am parsing a file and I would like to store it in a lookup structure in a way that I can lookup with two keys. I have a User Entity that has name, email and id, types are irrelevant. I would like to store it in a Dictionary<User, id> so I can get the user id by looking up with User. I also want the other way around, ie : Dictionary<...

Collection with multiple values in key

Hi. I'm looking for a Collection type data structure to implement the following. Say I have a class like this: class Person() { String homeTown; // key String sex; // key String eyeColour; // key String name; long height; // other stuff.... } I am processing multiple Person objects. I want to organise th...

Problems with casting LinQ result to strongly typed collection.

Hi guys. I guess this is trivial but not for me. I have a collection MembershipUserCollection. I wanted to perform some Linq query over it so I've used OfType<MembershipUser>() method and then applied Where() on it. However, I do not know how to cast back my results to MembershipUserCollection? This is my code: MembershipUserCollectio...