Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3354614
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:17:40+00:00 2026-05-18T02:17:40+00:00

Consider this class: public class Foo { // Fields private string _bar; // Properties

  • 0

Consider this class:

public class Foo
{
    // Fields
    private string _bar;

    // Properties
    private string Bar
    {
        get
        {
            return this._bar;
        }
        set
        {
            this._bar = value;
        }
    }
}

Now when I go and look in the IL code emitted by the compiler for the setter of the Bar property:

.method private hidebysig specialname instance void set_Bar(string 'value') cil managed
{
    .maxstack 8
    L_0000: nop 
    L_0001: ldarg.0 
    L_0002: ldarg.1 
    L_0003: stfld string ConsoleApplication2.Program/Foo::_bar
    L_0008: ret 
}

Why does it do a ldarg.0 ? WHAT is located in first (index 0) argument? Since the method/property setter only takes 1 argument…

The same goes for the getter:

.method private hidebysig specialname instance string get_Bar() cil managed
{
    .maxstack 1
    .locals init (
        [0] string CS$1$0000)
    L_0000: nop 
    L_0001: ldarg.0 
    L_0002: ldfld string ConsoleApplication2.Program/Foo::_bar
    L_0007: stloc.0 
    L_0008: br.s L_000a
    L_000a: ldloc.0 
    L_000b: ret 
}

Why the .locals init ? Why the ldarg.0 ? Why doesn’t it do a ldfld of the backing field and just return that? 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:17:41+00:00Added an answer on May 18, 2026 at 2:17 am

    For the setter:

    Any instance member has an implicit “this” parameter – that’s what’s being loaded, basically. Try turning it into a static property and you’ll see it go away.

    For the getter, I’m not sure why there’s the local variable… debugger support perhaps? Certainly compiling it in optimized mode (/o+ /debug- from the command line) gets rid of the local variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this abstract class public abstract class Foo { public Injectable Prop {get;set;} }
Consider this: public class TestClass { private String a; private String b; public TestClass()
Please consider this example class: [Serializable] public class SomeClass { private DateTime _SomeDateTime; public
consider the following class and struct public class Entity { public IdType Id {get;set;}
I have a class Bar with a private field containing the reference type Foo
Consider the following template class class MyClassInterface { public: virtual double foo(double) = 0;
I have an interesting problem. Consider this class hierachy: class Base { public: virtual
Consider this example (typical in OOP books): I have an Animal class, where each
consider this code block public void ManageInstalledComponentsUpdate() { IUpdateView view = new UpdaterForm(); BackgroundWorker
Consider this code (Java, specifically): public int doSomething() { doA(); try { doB(); }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.