.net - Get The Difference Of Two Arraylists?
Jul 2, 2010I have two arraylists, and I would like to have a new arraylist with only the uncommon items. Is this the "best" or at least decent way to do it?
[Code]...
I have two arraylists, and I would like to have a new arraylist with only the uncommon items. Is this the "best" or at least decent way to do it?
[Code]...
OK, so I am creating a bit of code that will allow me to randomly pick one "card" from a "deck", delete that "card" from the deck, and repeat. I found in all of my research that vb.net has the arraylist that is supposed to be very simple in these situations. However, when I try to populate them with a For Each statement, I only get odd numbers in the array list. What am I missing?
Dim a As New ArrayList
For i As Integer = 1 To 52
a.Add(i)
[code].....
I have two arraylists that contains links in one and the root url in the other. Sometimes the lists dont equal in number and I would like to iterate through the links list and if it contains a matching root url add it to a third list but also avoid any duplicates. I tried this but am not getting consistent results.
For Each link As String In urls
For Each part As String In post
If part.Contains(link) Then
[code]....
Perhaps there is another way; basically the part in post is a link to a page and contains the root url( which is link in urls). After extracting all these I need to ensure the 2 lists match.
I was trying to use ArrayLists with My.Settings but I can't seem to figure out how to get them to work.If I make a setting called "Words" and make it an ArrayList without a value, the program has an error every time I try to run it. If I try to give it a value in the project properties window it always gives me an incorrect data type error. Besides, I don't want it to have a value, I want it to be blank such as when declaring a New ArrayList. The only way I can get an ArrayList My.Setting to work is by clicking in the Value box, clicking the "..." button in the corner and adding some kind of Object with the add button. This automatically puts some kind of wierd object in the first index of the array list. If I don't convert Item(0) of the arraylist to a string then it also gives me an error when I try to read it. As a string it comes up as System.Object. Even though I can use the my.settings.Words ArrayList with an object in the first index, how can I get the setting to start off blank without having to constantly avoid the first index?
View 10 RepliesI have been tempted to use List(Of T) in VB.NET instead of ArrayLists by someone-who-must-not-be-named-Robinson.Essentially, what I need to store are three things: One string, two integers, and maybe two booleans. I liked using ArrayList, because it treated all its elements as "Objects" so I didn't really have problems storing that variety of elements.But now I have been thinking on using List(Of T). But how do I do to store that variety of elements of mine? I have been thinking on making a Structure holding the five elements.Sounds like a good idea? I heard somewhere that Structures are expected to have a short life. But I fear I will be having my structures for... forever, as long as my app lives. That makes any difference? Finally, what if I needed to create... dunno...... 125000000 Lists, each containing a structure? Is that possible (and good)?
View 2 RepliesI have two array lists
dim Colors1 = New ArrayList
Colors1.Add("Blue")
Colors1.Add("Red")
[code]....
I would like to find out which colors are missing from Colors2 that are found in Colors1
I have three arraylists (datasets and subsets) that I need to combine into one arrraylist so I can databind it to a repeater control and then present data to the user. As far as I know, you can only bind the repeater with one datasource (please correct me if this is wrong) that's why I'm combining these arraylists.Each arraylist has an ID from the database which I can use as a datakey to keep the data aligned. How do I combine these lists?
View 4 RepliesI have searched high and low for a solution yet still no luck, I have two arraylists populate with FileInfo and I want to compare the two and write the duplicate (matching files) to a listbox.Here is how I have populated the arraylists but in terms of the comparison I have not found anything that works:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim arraylist1 As ArrayList
Dim arraylist2 As ArrayList
[code]....
What can I do next to compare the two and write the duplicates to ListBox1.
I have two arraylists that contains links in one and the root url in the other. Sometimes the lists dont equal in number and I would like to iterate through the links list and if it contains a matching root url add it to a third list but also avoid any duplicates. I tried this but am not getting consistent results.
[Code]...
I am trying to convert an algorithm to use them in order to save memory. However, I am struggling to achieve error-free code while using "Strict On".
Here is a basic version of the code I am attempting to use.
Code:
Option Explicit On
Option Strict On
Module Program
[Code]...
It works when I do not use the Strict option. How do I improve the code to compile error-free?
Background: I'm writing a application that will allow users to enters items on a form using textboxes, radio buttons and checkboxes. I then take each input item and write it to it's own arraylist. After the user is all done entering data the information in the arraylists will write out to a single .txt file.
View 6 RepliesI have two arraylists that contains links in one and the root url in the other. Sometimes the lists dont equal in number and I would like to iterate through the links list and if it contains a matching root url add it to a third list but also avoid any duplicates. I tried this but am not getting consistent results.
[Code]....
I've got three arraylists of strings, and the "091: " part of the string is not part in the arraylist, thats added when I display them in the listboxes. So basically, how can I sort a list, and make sure that item nr 98 in english, still equals nr 98 in japanese and kanji?
View 11 RepliesI am obviously not understanding something about scoping that is very basic. I have a very simple class:
Public Class testListClass
' This just contains a single list that is set by a property or the constructor
Private classArrayList As New ArrayList()
[code].....
I did this before, but i totally forgot how to do it.I have an array, the array contains strings with 2 seperators.like so:
name1 / name2 / name3
Basicly i want name1, name2, and name3 in 3 seperate lists, or arraylists. But, i don't know how to do it.Each line is being read from a file.
I'm sure this is straightforward but I cannot find the correct string to get a google result. In VB.NET what is the difference between = (equals sign) and := (colon followed by equals sign)?
View 3 Repliescan anyone tell me book for VB.net for beginner and complee package of books important for VB. as i don't know anything abt VB.
what is difference between VB.net and asp.net and c#??
Possible Duplicate: What are the most important functional differences between C# and VB.NET? What are the basic difference between c# and VB.net?
View 3 Repliesknow the difference between C#.Net and VB.Net. I use C#.Net for my projects, but when ever I met with some other programmers they often called VB.Net more powerful and easy, than C#.Net. I always asked them "Why it is more powerful then C#, since it uses the same framework?" but still I didn't get any answers.
View 3 Replieswhat exactly distinguishes a COM component from a DLL? Isn't a COM component just a library of functions that can be called from another application? Why is using a COM component so much more complicated than just registering it like one would do with a DLL?
View 4 RepliesI'm looking for an explanation of the difference between
Dim sw1 = New StringWriter()
Dim sw2 As New StringWriter()
Both seem to instantiate new string writer instances that I can use.
I was under the assumption that VB's For Each loop was the same as a For Next loop. But when i try running the following code I do not get the expected result.
[Code]...
I have this code, first I thougt it should be the same but i cant acces the info in the same way .. why is this???
Dim tp(,) As Integer = {{1, 3, 5, 9, 7}, {34, 3, 4, 5, 6}}
Dim tpo(1)() As Integer
tpo(0) = New Integer() {1, 3, 5, 9, 7}
[code].....
The first one I use only one for each and the other one I use two .. why is this different? are noy they 2 dimensional arrays ???
What is the difference between VB and VB.NET?
explanation with examples preferred
The next code works fine in C#:
[Code]...
But this code crash with a OverflowException in VB.Net.
[Code]...
Both codes seems the same to me. What is the difference and how can I get the C# code converted to VB.Net?
For those who have experience, working with VB.NET, it's easier to use SlimDX or SDL? The tutorials for SlimDX are already written for .NET, but I've read that SDL it's a lot easier than DirectX itself.in my case, I just need 2D graphics.
View 4 Replies[Code].....
What is the major difference between 'for each' and 'for' loops in .NET? Is there any performance gain while comparing these two? Which one gives a better performance/faster/memory management?
I have in the past used .net executables as libraries. I'd just add them to the references in visual studio and I was ready to go. Today I tried the same to a new exe (actually mine) and it doesn't seem to work. When I add it to Visual Studio and try to watch its members on the Object Browser, it doesn't show up anything inside that executable's assembly.
I know the main difference between an exe and dll is that the first has an entry point while the 2nd doesn't. Are there any more differences? I know that unmanaged dll's also have a DLL entry point, do .net have one too?Also, what might be the reasons that could make my standard exe/dll (with this i mean, not obfuscated or anything extreme like that) not show up anything in the Object Browser?
What's the difference between / and for division in vb.net? My code gives very different answers depending on which I use. I've seen both before, but never knew the difference.
View 3 RepliesI am trying to find the difference between two dates. The first of the two dates can be changed and when it is changed, the difference between the original dates has to be retained. This means that I have to automatically change the second date to have the same difference in days as it did before, but with a new first date. [code]I have the value of the old date1(currDate) and the new date1 value(newDate). I need to get the difference between these, and then add or minus these days from the endDate.
View 1 Replies