Differences Between A HashSet(of T) And A List(of T)
Oct 10, 2011
What are the differences between a HashSet(of T) and a list(of T). I recently discovered HashSet and it seems to be substantially faster and uses much less memory than a list, so why use a list at all ?
View 5 Replies
ADVERTISEMENT
Sep 20, 2010
Would the following:
Dim stringlist As List(Of String)
Dim stringlisthas = stringlist.Contains("thing1")
be any slower than
Dim stringlist As List(Of String)
Dim stringlisthash As New HashSet(Of String)(stringlist)
Dim stringlisthas = stringlisthash.Contains("thing1")
Is a hashset needed for contains?
View 1 Replies
Nov 17, 2010
know where I can get a list of the differences between VB.Net versions? For example, in which version were generics first introduced, and when did the "Using" keyword come into being?
I've tried googling it and all I seem to get are the differences between VB6 and VB.Net, which isn't what I'm after.
View 2 Replies
Jul 26, 2011
I know that the .Contains method on a hashset is fast. My question is what is the best method for getting the hashset data before repetitively using the .Contains method?
I can think of 2 options. Both of these examples would be called in a loop of undetermined length.
1) Call the method that returns the cached hashset directly and use the .Contains method.
IF (GetHashSetMethod.Contains("TESTVALUE") THEN BLAH, BLAH, BLAH...
2) Create a new hashset outside of the loop and load the cached hashset data into it so the method that returns the hashset is only called once, then use the .Contains method.
DIM HashTest AS HASHSET(OF String) = GetHashSetMethod
Then in loop:
if (HashTest.Contains("TESTVALUE") THEN BLAH, BLAH, BLAH...
I have been using method 1. Should I even think about switching to method 2? Is there a 3rd option I haven't even thought of? Does it even matter because the data is cached to begin with?
View 2 Replies
May 30, 2010
I created a custom class which just stores 3 byte values, (R G B to be exact), which constantly change. So my idea was to store that class in a HashSet, then create a new instance of the class (with different byte values) then add that to the HashSet. There can be duplicates, which is why I decided to use a HashSet, which will ignore an item if it's allready been added. Doing this on a List would be too slow.But I've ran into a problem. Adding a custom class to hashset seems to only allow 1 to be added. I assume this is because its hashing the class object while ignoring the data (byte rgb values) it contains? Is there a way around this? It's possible to convert the RGB to Color and just use that in the HashSet, but conversion is a bit too slow.
View 2 Replies
Dec 21, 2011
How do I Display A HashSet As Either A Collection or an Array in the PropertyGrid.I wish there was some Attribute that allow me to display IEnumerable as an Array...but so far my attempts to do that have failed!My current solution is unacceptable in the new places I want to use it in
[Code]...
View 3 Replies
Jan 10, 2010
I am trying to generate random images from access database using hashset as it is said to be unique and there won't be any repeated images appearing. But, it doesn't seem to work. ow can i get it to work? By the way, i am very new to the concept of hashset.
Private Function GetImageFromByteArray(ByVal picData As Byte()) As Image
If picData Is Nothing Then
Return Nothing
[code].....
View 1 Replies
Jun 22, 2010
I am trying to generate random images from access database using hashset as it is said to be unique and there won't be any repeated images appearing. But, it doesn't seem to work.
How can i get it to work? By the way, i am very new to the concept of hashset.
Private Function GetImageFromByteArray(ByVal picData As Byte()) As Image
If picData Is Nothing Then
Return Nothing
End If
' is this is an embedded object?
Dim bmData As Integer = If((picData(0) = 21 AndAlso picData(1) = 28), 78, 0)
' load the picture
Dim img As Image = Nothing
Try
Dim ms As New MemoryStream(picData, bmData, picData.Length - bmData)
img = Image.FromStream(ms)
Catch
End Try
' return what we got
Return img
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Panel1.Visible = False
Panel2.Hide()
Dim conn As New OleDbConnection
Dim DA As OleDbDataAdapter
Dim DS As New DataSet
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db1.mdb;User Id=admin;Password=;"
DA = New OleDbDataAdapter("Select Empty, EmptyName, Target, TargetName from PicturesDisplayed", conn)
DA.Fill(DS)
Me.PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
Dim oledbconnection As OleDbConnection
oledbconnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Documents and SettingsAdministratorDesktopdb1.mdb;Jet OLEDB:System Database=system.mdw;")
oledbconnection.Open()
Dim command As OleDbCommand
command = New OleDbCommand("select count (*) from PicturesDisplayed", oledbconnection)
Dim count As Integer
count = command.ExecuteScalar()
oledbconnection.Close()
Dim randomImage As New HashSet(Of Integer)
' Create a integer and new Random object
Dim intPic As Integer
Dim rand As New Random
'Pick a random number between 0 and the number of images in database
intPic = rand.Next(0, count)
randomImage.Add(intPic)
PictureBox1.Height = 256
PictureBox1.Width = 256
PictureBox2.Height = 256
PictureBox2.Width = 256
Dim pic1x As Integer = _
(Me.ClientSize.Width - PictureBox1.Width) 2
Dim pic1y As Integer = _
(Me.ClientSize.Height - PictureBox1.Height) 2
PictureBox1.Location = New Point(pic1x, pic1y)
Dim pic2x As Integer = _
(Me.ClientSize.Width - PictureBox2.Width) 2
Dim pic2y As Integer = _
(Me.ClientSize.Height - PictureBox2.Height) 2
PictureBox2.Location = New Point(pic2x, pic2y)
' Now set the picturebox image equal to the image chosen from the array randomly using the random
PictureBox1.Image = GetImageFromByteArray(DS.Tables(0).Rows.Item(intPic).Item(0))
PictureBox1.Visible = True
PictureBox2.Image = GetImageFromByteArray(DS.Tables(0).Rows.Item(intPic).Item(2))
PictureBox2.Visible = False
If (randomImage.Count = count) Then
Me.Close()
End If
End Sub
View 1 Replies
Aug 22, 2010
What are the differences between 32 and 64-bit .NET (4) applications?Often 32-bit applications have problems running on 64-bit machines and conversely. I know I can declare an integer as int32 and int64 (certainly int64 on 32-bit systems make problems). Are there other differences between programming an 32 OR 64-bit or a both 32 AND 64-bit compatible application?
View 2 Replies
Aug 10, 2010
Would like to build an application and was wondering why someone would choose one language over another.Also is one language used more for a particular type of programming then another (For example, is VB used more for business or Windows development then for web development ?)
View 1 Replies
Aug 14, 2009
I am currently learning visual basic 5 on my home computer. I was wondering if someone could tell me what the major differences are between Visual basic 5 and the latest/new editions of VB.
View 3 Replies
Jan 14, 2010
We have legacy character codes that we want to store as numbers in a new system. To increase readibility and general understanding in the code for devs making the migration, I want to do Enums like this..
[Code]...
With this setup, the code will be readable (imagine If Record.Status = Status.Open), and yet the values will be stored in the database as small numbers so it will be efficient. However... I am a VB.NET guy, but everybody wants to code in C#, so I need this sort of structure in C#.After Googling, I discovered the the general .NET equivalent of AscW is Convert.ToInt32("C"). When I try to use that statement in an enum, I get the compiler error "Constant Expression Required".
View 2 Replies
Dec 13, 2011
in order for me to get help on me and my programming partners vb6 rpg, I have to upgrade the project to the vb.net platform, and I am worried that the IDE interface that is used to program the vb side of the rpg is different, so I am wanting to ask any of you if there are any significant changes to the IDE or if it is relatively the same as it was in vb6... I am also hoping that someone here can also help me to see what is wrong with my load/save function... I now thought of something to try to see if that is the issue or not, but the code is still vb6 code, the only difference will be that the program will be upgraded to the .net platform, so if that changes anything in the code, then I am not aware of this as of yet, because I am still downloading the visual studios 2010 express iso right now... so I do not know for sure yet what will be changed.
View 3 Replies
Dec 18, 2011
Does anyone know how to implement in VB an algorithm for final differences that changes the network (the matrix) during the computation (decrease its dimensions)?
View 1 Replies
Aug 26, 2011
Today I was playing around with Entity Framework and I've read that the generated IL for C# was different than VB.NET for the following code:
[code]...
As it seems the VB.NET version of this code will contact the database every time the code is executed while the C# version will retrieve the entities from the cache when the code is executed multiple times.Why would they make both languages behave in such a different manner?It was my misconception that both languages just differed in syntax and had almost exactly the same generated IL.Are there any more examples where both languages generated such different IL?
View 2 Replies
Jan 17, 2011
what can C# do that VB.Net can't ? VB.net vs C#.net
main differences between visual basic and C# as well as the pros and cons between the two?
View 1 Replies
Jul 18, 2011
Well i want to compare 2 strings (version one and version two) and get the differences in a format that i can convert to html on my own, like you can view how a post was edited here on stack*overflow* or like svn tracks differences between revisions....
It must be full managed code library.
Like this JavaScript but i need to do it on the server-side..
View 2 Replies
Mar 9, 2012
I've heard that the c# garbage collector can be 'more aggressive' than it's vb.net counterpart. Is this true? Are there any other differences in how garbage collection is run in vb.net vs. c#?
View 5 Replies
Oct 26, 2011
i'm using Enumerable.Except to check if a DataTable in memory is in sync with the table in database.
The background is: this DataTable and other frequently used tables are stored in the Cache of a WebApplication. But meanwhile i'm convinced that this is not a good approach because it's a source for nasty errors that are difficult to reproduce/debug.
Therefore i've created a function that checks if database and memory are in sync, otherwise an error-log will be created. This works perfectly. If there is a row in memory that is not in database, this row will be shown below "Difference in database", the same applies in reverse. But if rows exist in both datasources(the PK idRMA) and some values differ, the log will contain this row in two versions(below "Difference in database" and "Difference in database"). It is not easy to see the differences on the first sight.
Q: Is it possible to select only the properties that caused Except to think that first sequence is not in second?
This is the the complete function(the first lines are relevant):
Public Shared Sub CheckRmaMemoryInSyncWithDB()
Dim inSyncText As String
Dim color As Drawing.Color
[Code]......
View 3 Replies
Jan 13, 2010
I am using asp.net and the .net framework 2.0. I may be able to upgrade the servers to 3.5 if the solution is compelling enough. Here is the problem. I have two pieces of xml. I'll refer to piece number 1 as the template and piece number 2 as the actual. Here's a basic example:
[Code]...
View 2 Replies
Nov 16, 2011
I just found an interesting problem between translating some data:
VB.NET: CByte(4) << 8 Returns 4
But C#: (byte)4 << 8 Returns 1024
[code].....
View 3 Replies
Sep 24, 2009
I have 2 text boxes and I load a text file in to each box, the files contents are "almost" exactly the same but not 100%. how would i compare the 2 against eachother and output the difference in percentage? I've made a program once before it was pretty cool it did all these things and it was in VB.Net i just cant remember how i did it.. i do know i counted how many of the sames words exist but i cant remember what else i did.
View 10 Replies
Feb 17, 2011
Compare differences between lists?I have two sets of lists below[code]...
View 1 Replies
Sep 16, 2011
In VB, when we adding a new references - in my case web references -, it simply type namespace followed by the class name to make a new object.For example:
Dim obj As NamespaceName.ClassName = New NamespaceName.ClassName
Then I apply this concept in C#. So my code will be:
NamespaceName.ClassName obj = new NamespaceName.ClassName
...and it doesn't work.Actually, is there any difference about Importing Namespace between those two?And also can you give me a little explanation about Project-Wide Default Namespace Imports in VB?
UPDATE:My point is why "In C#, When I've typed NamespaceName, the ClassName was not listed in the Intellisense?".However, it did well in VB, do I have to import something?Maybe, there is something to do with the term "Project-Wide Default Namespace Imports". (CMIIW)
View 3 Replies
Jun 9, 2010
differences between HttpWebRequest and WebClient and why I should use either.
View 1 Replies
Jun 22, 2010
what differences between vb2008 and vb2010.(OOP)
View 3 Replies
Jun 29, 2011
After I have programmed several projects in VB.Net I to my surprise discovered that there are some more than subtle differences between C# and VB.NET LINQ usage.For example, if we want to group elements by multiple properties (columns) we need to create a new anonymous type explicitly:
var procs = from c in Process.GetProcesses()
group c by new {c.BasePriority, c.Id} into d
select d;
whereas in VB.NET more straightforward syntax will already do:
Dim b = From c In Process.GetProcesses()
Group c By c.BasePriority, c.Id Into Group
Select Group
So, one does not need to create a type with "new" here. What are the other differences? good comparison between the LINQ syntax in C# and VB.NET?
View 2 Replies
Nov 18, 2010
NET gurus... How would you convert this very chunk into VB?
[Code]...
When I use an online converter (Telerik), the middle line converts like this: Me.timer.Elapsed += New System.Timers.ElapsedEventHandler(ManageThreads) with 2 errors:
1- "Public eventElapsed is an event and cannot be called directly. Use raiseEvent
2- Delegate requires an Adess Of expression. Do I simply add "Address Of" ?
View 2 Replies
Oct 6, 2009
I am doing a project. I save a date in the registry. Now, I have to test this date against today's date and calculate the differences in minutes, hours, days, months, weeks and years.I save the date in the registry like this:
Code:
Application.UserAppDataRegistry.SetValue("Date", [Date])
I then made a sub to calculate the differences:
[code].....
View 1 Replies
Nov 16, 2011
I have noticed that the immediate window in VS 2010 behaves differently when debugging a C# project and a VB.NET project, although I haven't been able to find any specific documentation of this difference.
For C# projects, I can simply type in any expression, and it will be evaluated and displayed, i.e.
[Code]...
All other expressions exhibit the same behavior, including simple math such as '1 + 2'. Sometimes the error message is different though, as 1 + 2 results in the error 'Labels that are numbers must be followed by colons.'Is there a way to 'fix' this behavior and make the VB.NET immediate window behave more like the C# one? Having to type a ? in front of every statement can be a pain when using it frequently.
View 2 Replies