Suppose I have a static property like the following:
public static object MyProperty
{
get { return new object(); }
}
Is the above property the same of?
private static object my_filed = new object();
public static object MyProperty
{
get { return my_filed; }
}
I.e: Is the new object created each time I call my static property or only the first time?
The property getter is executed every time the property is read, so it will create a new object instance every time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With