I want an array of classes as a protected property m_PhraseExceptionList() with a public read-only property PhraseExceptionList() out in front of it. This array would be initially empty; it will be loaded with some unknown number of elements at runtime.
The class that the array holds is just a container for 2 string properties. It is called PhraseRule.
I have the protected property defined as follows:
Protected Property m_PhraseExceptionList() As PhraseRule
This produces a compile-time syntax error.
If I change it to:
Protected Property m_PhraseExceptionList(0) As PhraseRule
… the property compiles, but attempts to work with it yield “Type mismatch error. Expected class PhraseRule, but got class PhraseRule”.
So ignoring the incoherent error message … what am I doing wrong?
Type mismatch error. Expected class PhraseRule, but got class PhraseRule
Return m_PhraseExceptionList
Also these 2:
Type mismatch error. Expected String, but got Int32
paddedString = paddedString.Replace(paddedString, pr.Phrase, pr.Correction)
There is more than one method with this name but this does not match any of the available signatures.
paddedString = paddedString.Replace(paddedString, pr.Phrase, pr.Correction)
Those last 2 I have seen when the compiler is just confused or fails to actually define a type, and then runs home to Int32, and hilarity results. So I think the actual problem is that while the property definition is compiling, it’s still not making it clear to the compiler what I actually want.
For thoroughness, here’s the PhraseRule class definition:
Protected Class PhraseRule
Sub Constructor(p As String, c As String)
Phrase = p
Correction = c
End Sub
Correction As String
Phrase As String
End Class