I would suspect the code below for output:
(I am a SmartForm object and use the method in SmartForm) .xml
instead, it produces:
(I am a SmartForm object and use the method in Item) .xml
Why? How can I get C # to accept a value from an overriding property? That is why I am redefining a property.
using System; namespace TestInhersdk234 { public class Program { static void Main(string[] args) { SmartForm smartForm = new SmartForm(); Console.ReadLine(); } } public class SmartForm : Item { public SmartForm() { Console.WriteLine(FullXmlDataStorePathAndFileName); } public new string GetItemTypeIdCode { get { return String.Format("(I am a {0} object and using the method in SmartForm)", this.GetType().Name); } } } public class Item { public string FullXmlDataStorePathAndFileName { get { return GetItemTypeIdCode + ".xml"; } } public string GetItemTypeIdCode { get { return String.Format("(I am a {0} object and using the method in Item)", this.GetType().Name); } } } }
source share