I am building the 'TheBeerHouse' project in
vb.net (the book is written in C#). Once I understand the concepts, I can usually convert it to
vb. However, there are a few areas that give my some problems (which I will address individually). The first issue I have is the C# 'base' to
VB 'MyBase'.
Here is the C# code I am trying to convert:
Code:
namespace TheBeerHouse.Configuration
{
public class TheBeerHouseSection : ConfigurationSection
{
public readonly static TheBeerHouseSection Current = (TheBeerHouseSection)WebConfigurationManager.GetSection("theBeerHouse");
[ConfigurationProperty("articles", IsRequired = true)]
public ArticlesElement Articles
{
get { return (ArticlesElement)base["articles"]; }
}
}
}
And here is
VB.Net converted code:
Code:
Namespace TheBeerHouse.Configuration
Public Class TheBeerHouseSection
Inherits ConfigurationSection
Public Shared ReadOnly Current As TheBeerHouseSection = DirectCast(WebConfigurationManager.GetSection("theBeerHouse"), TheBeerHouseSection)
<ConfigurationProperty("articles", IsRequired := True)> _
Public ReadOnly Property Articles() As ArticlesElement
Get
Return DirectCast(MyBase("articles"), ArticlesElement)
End Get
End Property
End Class
End Namespace
My understanding of this conversion is that I need to grab the attributes of the <articles> element under the <theBeerHouse> custom section in the web.config file.
This code does not compile and the get the following error: 'MyBase' must be followed by '.' and an identifier.
Thanks,