|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
List.Contains(searchValue)I have a class object: public class exampleList() { public int prop1 {get; set;} public string prop2 {get;set:} } Now in a method in the exampleList class I am retrieving data of this class type and trying to check if the prop1 value exists in the list by using the List.Contains method. private void FetchData() { exampleList objBAO = new exampleList (); List<exampleList > objList = new List<exampleList>(); objList = objBAO.Fetch(); //another routine that goes to the database to get the data and returns it in a List<> //The below code is not working. I just want to pass an integer value to see if it is in the list if (!objList.Contains(this.prop1)) { //code to process results } } "John Crews" <trex3***@hotmail.com> wrote in message [Canned response]news:uDaWy6YpJHA.6132@TK2MSFTNGP06.phx.gbl... > I am trying to get teh List.Contains to work but I am having difficulty. This is a VB "classic" newsgroup. Questions about VB.NET (including VB 2005/2008, which have dropped .NET from their name) are off-topic here. Please ask .NET questions in newsgroups with "dotnet" in their names. The *.vb.* groups are for VB6 and earlier. If you don't see the *.dotnet.* groups on your news server, connect directly to the Microsoft server: msnews.microsoft.com. For questions specific to the VB.NET language, use this group: microsoft.public.dotnet.languages.vb Please note that things like controls and data access, which have their own subgroups in the Classic VB hierarchy, are not language-specific in .NET, so you should look for groups like these: microsoft.public.dotnet.framework.windowsforms.controls microsoft.public.dotnet.framework.adonet (Note that "vb" is not present in the group name.) "Jeff Johnson" <i.get@enough.spam> wrote in message That code was probably C#news:u1gtbyapJHA.3868@TK2MSFTNGP02.phx.gbl... > "John Crews" <trex3***@hotmail.com> wrote in message > news:uDaWy6YpJHA.6132@TK2MSFTNGP06.phx.gbl... > >> I am trying to get teh List.Contains to work but I am having difficulty. > > [Canned response] "Bill McCarthy" <TPASoft.com Are Identity Thieves> wrote in message HAHAHAHAHA!! I even read through it and didn't notice! Guess that's what you news:%23fIr83bpJHA.4516@TK2MSFTNGP02.phx.gbl... >>> I am trying to get teh List.Contains to work but I am having difficulty. >> >> [Canned response] > > That code was probably C# get when you're sitting around coding in C# and you pop into a VB group!
Show quote
Hide quote
"Jeff Johnson" <i.get@enough.spam> wrote in message LOl. I never have that problem reading the code.. but if I've been writing news:%23L1m6TrpJHA.3380@TK2MSFTNGP04.phx.gbl... > "Bill McCarthy" <TPASoft.com Are Identity Thieves> wrote in message > news:%23fIr83bpJHA.4516@TK2MSFTNGP02.phx.gbl... > >>>> I am trying to get teh List.Contains to work but I am having >>>> difficulty. >>> >>> [Canned response] >> >> That code was probably C# > > HAHAHAHAHA!! I even read through it and didn't notice! Guess that's what > you get when you're sitting around coding in C# and you pop into a VB > group! in it for even half an hour I find it really hard not to add ; everywhere when I switch back to VB ;) Hi John,
Your code looks like it is C#, in which case best to ask in a CSharp newsgroup such as : microsoft.public.dotnet.languages.csharp Most likely the suggestions will be to use a Dictionary<int, exampleList> or a comparer with the list, but best top have that discussion in the c# forums as there are many alternatives, few if any oif which apply to early (pre ..NET) versions of VB. "John Crews" <trex3***@hotmail.com> wrote in message I am trying to get teh List.Contains to work but I am having difficulty.news:uDaWy6YpJHA.6132@TK2MSFTNGP06.phx.gbl... I have a class object: public class exampleList() { public int prop1 {get; set;} public string prop2 {get;set:} } Now in a method in the exampleList class I am retrieving data of this class type and trying to check if the prop1 value exists in the list by using the List.Contains method. private void FetchData() { exampleList objBAO = new exampleList (); List<exampleList > objList = new List<exampleList>(); objList = objBAO.Fetch(); //another routine that goes to the database to get the data and returns it in a List<> //The below code is not working. I just want to pass an integer value to see if it is in the list if (!objList.Contains(this.prop1)) { //code to process results } }
Other interesting topics
VB App fails when log reaches 65536
Internal String Visibility Help with Binary Compatibility Fonts HOW IS Memory Used by a VB App vb.net executing on (OT) false positives on my files Can I loop through only SELECTED items in a multi-select FileListBox? Is it possible to remove 3rd party app icon from systray? Should I distribute Winsock? |
|||||||||||||||||||||||