Creating property of type structure - error

Why can't I create a property of the type structure? I am getting the error: "TestTransakcje" cannot expose type "Transakcje" in namespace "BazyPolaczenia" via class "SklepPobieranieDanych".

Public Class SklepPobieranieDanych

    Private Structure Transakcje
        Public kontrahentNazwa As String
        Public listaTowarow() As Towary
    End Structure

    Private Structure Towary
        Public towarSymbol As String
        Public towarNazwa As String
        Public towarIlosc As Integer
        Public towarCena As Double
    End Structure

    Private _testTransakcje As New Transakcje

    Public ReadOnly Property TestTransakcje() As Transakcje  'Here is that error
        Get
            Return _testTransakcje
        End Get
    End Property
End Class

      

+3


source to share


1 answer


I assume this is because Transakcje

- Private

- you cannot deduce a type Private

from a member Public

: how would a consumer understand the type? Also note: public mutable fields are a very bad idea for a value type.

If I outweigh this in C #, the compiler error is:



Inconsistent availability: property type "SklepPobieranieDanych.Transakcje" is less accessible than property "SklepPobieranieDanych.TestTransakcje"

which makes the problem pretty clear.

+3


source







All Articles