c# - VB.Net 'Overridable' is not valid on a member variable declaration -
i'm using several code converters produce same vb.net coding vs not except line of code:
private overridable m_products icollection(of product)
vs states:
'overridable' not valid on member variable declaration.
the c# coding tutorial on asp.net web site at:
http://www.asp.net/web-forms/tutorials/aspnet-45/getting-started-with-aspnet-45-web-forms/create_the_data_access_layer
vs states should remove overridable keyword. if that, break in tutorial?
this c# coding i'm running through converters:
using system.collections.generic; using system.componentmodel.dataannotations; namespace wingtiptoys.models { public class category { [scaffoldcolumn(false)] public int categoryid { get; set; } [required, stringlength(100), display(name = "name")] public string categoryname { get; set; } [display(name = "product description")] public string description { get; set; } public virtual icollection<product> products { get; set; } } }
this result of conversion:
imports system.collections.generic imports system.componentmodel.dataannotations namespace wingtiptoys.models public class category <scaffoldcolumn(false)> _ public property categoryid() integer return m_categoryid end set m_categoryid = value end set end property private m_categoryid integer <required, stringlength(100), display(name := "name")> _ public property categoryname() string return m_categoryname end set m_categoryname = value end set end property private m_categoryname string <display(name := "product description")> _ public property description() string return m_description end set m_description = value end set end property private m_description string public overridable property products() icollection(of product) return m_products end set m_products = value end set end property private overridable m_products icollection(of product) end class end namespace
fields cannot overridable, property can. i'm not sure why converter created backing field @ all, can use vb.net's auto properties (if using visual studio 2010 or greater). try this:
imports system.collections.generic imports system.componentmodel.dataannotations namespace wingtiptoys.models public class category <scaffoldcolumn(false)> _ public property categoryid integer <required, stringlength(100), display(name := "name")> _ public property categoryname string <display(name := "product description")> _ public property description string public overridable property products icollection(of product) end class end namespace
Comments
Post a Comment