[Webinar] Learn how to a build a cloud-first strategyRegister Now


Can I declare the size of property array in vb.net?

Posted on 2012-09-18
Medium Priority
Last Modified: 2012-09-19
Can I declare the size of the array in the Property using the auto implement?

public class MySettings
 public Property LocalRooms() As  new Double (3)  <== I get an error saying there is no Double constructor

End class

Do I need to do it in the constructor?
Question by:dkim18
  • 2
LVL 83

Accepted Solution

CodeCruiser earned 1000 total points
ID: 38410554
You cant do it with auto implement. Either do full property or initialize it in constructor.
LVL 19

Assisted Solution

by:Shahan Ayyub
Shahan Ayyub earned 1000 total points
ID: 38413158
In VS2012, you can do like this:

which one you are using ?
LVL 19

Expert Comment

by:Shahan Ayyub
ID: 38413176
or something like this:

    Private locRooms() As Double

    Public Property LocalRooms() As Double()
            Array.Resize(locRooms, 3)   ' Here you can specify array size
            Return locRooms
        End Get
        Set(ByVal value As Double())
            Array.Resize(value, 3)   ' Here you can specify array size
            locRooms = value
        End Set
    End Property

Open in new window


Author Comment

ID: 38413502
Either do full property or initialize it in constructor.


Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month20 days, 10 hours left to enroll

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question