concept field in category .net

This is an excerpt from Manning's book AOP in .NET.
But with PostSharp, you’ll have some workarounds for sharing state between the boundary methods. First, you could use a field of the class itself, as in this listing.
You might not have heard the term location in reference to C#. A field is a location and a property is a location. The following code snippet contains two locations, one field and one property:
![]()
Fields and properties are common in OOP. They give data and structure to a class, as well as the ability to share information among the methods of a class.
The next section is a quick refresher on how fields and properties in C# work. If you feel comfortable in your knowledge of fields and properties, you can skim the next section. Remember that properties are just syntactic sugar for getter/setter methods.
A field is a class-level variable, which means you won’t find a way to explicitly specify how a field should get lazy loaded. Let’s make some assumptions to implicitly specify how the field should be loaded. First, let’s write code similar to the last section, but use a field instead of a property:
class Program { static SlowConstructor MyField; static void Main(string[] args) { MyField.DoSomething(); MyField.DoSomething(); } }The simplest thing you can do is use Reflection’s Activator to create an instance of the field’s type. Let’s create an aspect that does that. Start by creating a class that inherits LocationInterceptionAspect, and use it as an attribute on the field: