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. Visual Basic
  4. What am I missing?

What am I missing?

Scheduled Pinned Locked Moved Visual Basic
csharphelpquestion
4 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.
  • M Offline
    M Offline
    MikMit
    wrote on last edited by
    #1

    I am relatively new to .net. While I have dabbled in it, I haven't done anything serious. Now I'm trying to build a fairly complex dll/assembly and am running into a real frustration. I need to have a property that is both read/write and pulls/puts data into a collection based on a unique key. The problem is, I can't overload the set portion to allow for the key to be passed along with the value. Here are the examples of both uses: MyValue = Field(100) Field(100) = "Frank" I could do this very easily in VB6. I know this is more like a function than a property. Do I really need to write two functions with one overloaded? And if I do that, the second let syntax won't work. It would look like this: Field(100,"Frank") While that's useable, it's not very consistent or user-friendly for someone using this assembly. Not only that, it creates a real migration problem. Any suggestions would be greatly appreciated. CalmlyFrustrated

    D 1 Reply Last reply
    0
    • M MikMit

      I am relatively new to .net. While I have dabbled in it, I haven't done anything serious. Now I'm trying to build a fairly complex dll/assembly and am running into a real frustration. I need to have a property that is both read/write and pulls/puts data into a collection based on a unique key. The problem is, I can't overload the set portion to allow for the key to be passed along with the value. Here are the examples of both uses: MyValue = Field(100) Field(100) = "Frank" I could do this very easily in VB6. I know this is more like a function than a property. Do I really need to write two functions with one overloaded? And if I do that, the second let syntax won't work. It would look like this: Field(100,"Frank") While that's useable, it's not very consistent or user-friendly for someone using this assembly. Not only that, it creates a real migration problem. Any suggestions would be greatly appreciated. CalmlyFrustrated

      D Offline
      D Offline
      Dave Herren
      wrote on last edited by
      #2

      What you probably want is an indexor... read this. Indexers In C#[^]

      topcoderjax - Remember, Google is your friend. Try this Custom Google Code Search

      M 1 Reply Last reply
      0
      • D Dave Herren

        What you probably want is an indexor... read this. Indexers In C#[^]

        topcoderjax - Remember, Google is your friend. Try this Custom Google Code Search

        M Offline
        M Offline
        MikMit
        wrote on last edited by
        #3

        Thanks for the suggestion. This particular function/property doesn't necessarily have sequential numbering. It also has potentially 65535 indices. I don't really have a choice as to the structure (it's a file format of a third-party program). What I'm using in VB6 is perfect and I'm struggling with the idea that dot net can't do it. It feels like I'm going backwards porting things to dot net. Public Property Get Field(FldNo as Long) as String ..... code End Property Public Property Let Field(FldNo as Long, Value as String) ..... code End Property This allows the calling routine to address this property just like any other property. I originally wrote it as a method but the property approach is so much more convenient to code. CalmlyFrustrated

        D 1 Reply Last reply
        0
        • M MikMit

          Thanks for the suggestion. This particular function/property doesn't necessarily have sequential numbering. It also has potentially 65535 indices. I don't really have a choice as to the structure (it's a file format of a third-party program). What I'm using in VB6 is perfect and I'm struggling with the idea that dot net can't do it. It feels like I'm going backwards porting things to dot net. Public Property Get Field(FldNo as Long) as String ..... code End Property Public Property Let Field(FldNo as Long, Value as String) ..... code End Property This allows the calling routine to address this property just like any other property. I originally wrote it as a method but the property approach is so much more convenient to code. CalmlyFrustrated

          D Offline
          D Offline
          Dave Herren
          wrote on last edited by
          #4

          Indexors don't have to use sequential numbering, though that's probably what you saw in the example, you can do anything with the index and the value once you have them. The index doesn't even have to be number. But if you want another alternative you could declare a struct with a long and a string and have that be the Type of your property. No other options come to mind but good luck.

          topcoderjax - Remember, Google is your friend. Try this Custom Google Code Search

          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