Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
Do the set and get accessor of a Property (regular or auto-implemented) and Indexer also have a Stack-Frame on the Stack when executed?

Since a method (instance or static) has a Stack-Frame on the Stack when executed, I wonder if the same applies to the set and get accessor of a Property (regular or auto-implemented) and Indexer also have a Stack-Frame on the Stack when executed?

I was told the set and get acessors respresents "methods" for setting the value of a field (instance or static field) and retrieving the value of a field (instance or static field).Thus, me assuming that the both accessors (set and get) of a Property and Indexer to have a Stack-Frame on the Stack when executed. Can anyone confirm this for me or correct me if I'm wrong to assume this?

Bottom is a simple example of accessing the set and get accessor of an instance Property:

public class Program
{
    public static void Main(string[] args)
    {
        //Instance of class Person created
        Person person1 = new Person();

        //Accessing the set accessor of instance Property Name
        person1.Name = "John";

        //Accessing the get accessor of instance Property Name
        Console.WriteLine(person1.Name);
    }
}

public class Person
{
    private string name;

    public string Name { get { return name; } set { name = value; } }
}


What I have tried:

Unable to find answers to this online.
Posted
Updated 30-Jun-21 18:46pm
v2
Comments
Dave Kreskowiak 30-Jun-21 17:30pm    
Hi Jake!
[no name] 30-Jun-21 19:26pm    
Prove it to yourself with GetFrames; or don't you actually code?

1 solution

Just take the double quotes of the word "methods":
Quote:
I was told the set and get acessors respresents "methods" for setting the value of a field ...

They are methods; they are called as normal. Properties are just syntactic sugar to make the code easier to read.

Now, are you going to get abusive as usual, or should we just close this sock puppet like all your others before that happens?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900