After the last Assembly lesson in "What is the difference between Const and Readonly?" post, many of you praised and asked for more from the ildasm subject, so here it is, a simple question about the assembly behind you code.
What going to happen if you'll try to write this code:
public string HtmlSnippet { get { return m_HtmlSnippet; } set { m_HtmlSnippet = value; } } public string get_HtmlSnippet() { return m_HtmlSnippet; }
This one is simple, This is the error message at the compilation:error CS0111: Class 'Sentence' already defines a member called 'get_HtmlSnippet' with the same parameter types.
Why is it an error?while converting the C# Code into Assembly the compiler will transfer each property into method!after all, there are no properties in assemblies.The format of such transformation will be:public PropertyType get_PropertyName(){....}public void set_PropertyName(string value){....}
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.