-1

I have my below List of Structure which can add 3 items properly if I do :

newStructCheckTimer.Add(New StructCheckTimer(dateCheck, timeCheck, Filename))

I'm also able to delete a specific line if I write the below code, and enter all the details of each row:

newStructCheckTimer.Remove(New StructCheckTimer("8/8/2017", "9:15:00 PM", "C:\IBM\ICT\Project\Win App\bin\Debug\test 12"))

Now, I want to be able to delete the whole line only based on one column, I mean if I only enter the filename, it has to delete the whole line/index (will fill arbitrary info for me).

as I'm always supposed to fill the exact info (dateCheck, timeCheck, Filename) in order to delete, if I don't fill it with, it doesn't delete.

Structure StructCheckTimer
  Public chkDate As Date
  Public chkTime As Date
  Public chkFilename As String

  Public Sub New(ByVal verDate As Date, ByVal verTime As Date, ByVal verFilename As String)
    Me.chkDate = verDate
    Me.chkTime = verTime
    Me.chkFilename = verFilename
  End Sub
End Structure

Public newStructCheckTimer As New List(Of StructCheckTimer)
LarsTech
  • 80,625
  • 14
  • 153
  • 225
Alice
  • 95
  • 1
  • 9
  • See [Does it make sense to define a struct with a reference type member?](https://stackoverflow.com/a/5621610/719186) – LarsTech Aug 16 '17 at 19:15

1 Answers1

0

This is because by default structures are equal when all fields are equal. To change this behavior you must override Equals method of the structure, so that you can check whether some fields of compared structures are empty and then decide on equality. But rather use RemoveAll method:

https://msdn.microsoft.com/en-us/library/wdka673a(v=vs.110).aspx

Jan Muncinsky
  • 4,282
  • 4
  • 22
  • 40