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. how to return array from class property?

how to return array from class property?

Scheduled Pinned Locked Moved Visual Basic
csharphelpcsswinforms
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.
  • P Offline
    P Offline
    priya_p233
    wrote on last edited by
    #1

    Hello, i m using vb.net (winforms) & i have written class called employee. & make object of employee on my form & accessing all the properties of emp like id, name,sal etc. i shuld access all the values...so i wrotee property for each like Public ReadOnly Property BasicSal() As Integer Get Return BS1 End Get it is good whn property values are less but as i wnt to access all salary info like HRA, Basic Sal....etc total 20 fields. So i decided to use Array....I fill all values in array in my employee class's function itself. Th problem is i wnt to access this array of all values on my forms.How to do it plz tell me. Thanks for any help in advance. --Regards priya

    "The Difficult i can do it now... The Impossible will take a little longer."

    CPalliniC 1 Reply Last reply
    0
    • P priya_p233

      Hello, i m using vb.net (winforms) & i have written class called employee. & make object of employee on my form & accessing all the properties of emp like id, name,sal etc. i shuld access all the values...so i wrotee property for each like Public ReadOnly Property BasicSal() As Integer Get Return BS1 End Get it is good whn property values are less but as i wnt to access all salary info like HRA, Basic Sal....etc total 20 fields. So i decided to use Array....I fill all values in array in my employee class's function itself. Th problem is i wnt to access this array of all values on my forms.How to do it plz tell me. Thanks for any help in advance. --Regards priya

      "The Difficult i can do it now... The Impossible will take a little longer."

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      You can implement the property list using, for instance, a SortedList. See the following MSDN excerpt:

      Imports System
      Imports System.Collections
      Imports Microsoft.VisualBasic

      Public Class SamplesSortedList

      Public Shared Sub Main()
          
          ' Creates and initializes a new SortedList.
          Dim mySL As New SortedList()
          mySL.Add("one", "The")
          mySL.Add("two", "quick")
          mySL.Add("three", "brown")
          mySL.Add("four", "fox")
          
          ' Displays the SortedList.
          Console.WriteLine("The SortedList contains the following:")
          PrintKeysAndValues(mySL)
      End Sub    
      
      Public Shared Sub PrintKeysAndValues(myList As SortedList)
          Console.WriteLine(ControlChars.Tab & "-KEY-" & ControlChars.Tab & \_
             "-VALUE-")
          Dim i As Integer
          For i = 0 To myList.Count - 1
              Console.WriteLine(ControlChars.Tab & "{0}:" & ControlChars.Tab & \_
                 "{1}", myList.GetKey(i), myList.GetByIndex(i))
          Next i
          Console.WriteLine()
      End Sub
      

      End Class

      ' This code produces the following output.
      '
      ' The SortedList contains the following:
      ' -KEY- -VALUE-
      ' four: fox
      ' one: The
      ' three: brown
      ' two: quick

      Hope that helps :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

      In testa che avete, signor di Ceprano?

      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