Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Collection.IndexOf Method Question?

Collection.IndexOf Method Question?

Scheduled Pinned Locked Moved C#
questiondatabasehelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    haz13
    wrote on last edited by
    #1

    I can't seem to get my head around the following. My Frequency class has two fields Data1 and Data2. public static List ColourFreqCollection = new List(); ColourFreqCollection.Add(new Frequency(1,2)); ColourFreqCollection.Add(new Frequency(3,2));etc Is it possible to now use the IndexOf method to look in the Frequency objects Data1 field and return the index if a particular number exists? ColourFreqCollection.IndexOf(don't know what to put here! -look in object data1 field and return index if true); Else what would be the best thing to do? Thanks in advance for your help.

    Haz

    C 1 Reply Last reply
    0
    • H haz13

      I can't seem to get my head around the following. My Frequency class has two fields Data1 and Data2. public static List ColourFreqCollection = new List(); ColourFreqCollection.Add(new Frequency(1,2)); ColourFreqCollection.Add(new Frequency(3,2));etc Is it possible to now use the IndexOf method to look in the Frequency objects Data1 field and return the index if a particular number exists? ColourFreqCollection.IndexOf(don't know what to put here! -look in object data1 field and return index if true); Else what would be the best thing to do? Thanks in advance for your help.

      Haz

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      ColourFreqCollection.IndexOf(new Frequency(1,2)); That's all you can do, you don't have a reference to the object you're looking for.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups