Question Property declaration problems

Cort

Member
Joined
Jun 17, 2009
Messages
5
Programming Experience
Beginner
I am new to coding and VB. I imported a C# page into a converter and came out with this.

Two errors, one of which refers to this line: Public Shared ReadOnly Property DbProviderName() As String states that DBPRovider name is already declared as a string- which it is, of course. (Private Shared dbProviderName As String)

My question is does that mean I can get rid of that Property value?

I would note that the C# code does not come with this error; you can declare a static item first and then declare it again as a property.

VB.NET:
Imports Microsoft.VisualBasic
Imports System.Configuration
Public Class ECommerceConfig

    ''' <summary>
    ''' Repository for ECommerce configuration settings
    ''' </summary>
    Public Class ECommerceConfig

        ' Caches the connection string
        Private Shared dbConnectionString As String

        ' Caches the data provider name 
        Private Shared dbProviderName As String

        Shared Sub New()
            dbConnectionString = ConfigurationManager.ConnectionStrings("ECommerceConnection").ConnectionString
            dbProviderName = ConfigurationManager.ConnectionStrings("ECommerceConnection").ProviderName
        End Sub
        ' Returns the connection string for the BalloonShop database
        [B]Public Shared ReadOnly Property DbConnectionString() As String[/B]
            Get
                Return dbConnectionString
            End Get
        End Property

        ' Returns the data provider name
        [B]Public Shared ReadOnly Property DbProviderName() As String[/B]            Get
                Return dbProviderName
            End Get
        End Property
 
It means the property's name and the variable's name are the same, you could change it to:
VB.NET:
Public Shared ReadOnly Property ConnectionString() As String
and
Public Shared ReadOnly Property ProviderName() As String
Then when you use the properties outside of the class it's just 'ConnectionString' and 'ProviderName'
 
Back
Top