Raba - Defend your code RSS 2.0
# Saturday, January 28, 2006

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){....}

Saturday, January 28, 2006 4:35:52 PM (GMT Standard Time, UTC+00:00)  #    Comments [1] - Trackback
.Net

Archive
<January 2006>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234
Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Shani Raba
Sign In
Statistics
Total Posts: 145
This Year: 0
This Month: 0
This Week: 0
Comments: 97
Cool Stuff
Add to Technorati Favorites
Themes
Pick a theme:
All Content © 2012, Shani Raba
DasBlog theme 'Business' created by Christoph De Baene (delarou)