# C++ Properties with Getters/Setters

UnrealSharp will attempt to pair up C++ member variables with their designated getters/setters and call these functions rather than setting the value directly in memory.&#x20;

It also supports the new native Getter/Setters workflow that was implemented in 5.1.

The following C++ member:

```csharp
UPROPERTY(BlueprintGetter=K2_GetRootComponent, Category="Transformation")
TObjectPtr<USceneComponent> RootComponent;
```

maps to this C# code, which calls `K2_GetRootComponent` to retrieve the value:

```csharp
public UnrealSharp.Engine.USceneComponent RootComponent
{
    get
    {
        unsafe
        {
            byte* ParamsBufferAllocation = stackalloc byte[K2_GetRootComponent_ParamsSize];
            nint ParamsBuffer = (nint) ParamsBufferAllocation;
            UStructExporter.CallInitializeStruct(K2_GetRootComponent_NativeFunction, ParamsBuffer);
            
            UObjectExporter.CallInvokeNativeFunction(NativeObject, K2_GetRootComponent_NativeFunction, ParamsBuffer);
            
            UnrealSharp.Engine.USceneComponent returnValue;
            returnValue = ObjectMarshaller<UnrealSharp.Engine.USceneComponent>.FromNative(IntPtr.Add(ParamsBuffer, K2_GetRootComponent_ReturnValue_Offset), 0);
            
            return (UnrealSharp.Engine.USceneComponent)returnValue;
        }
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.unrealsharp.com/unreal-framework/classes/properties/c++-properties-with-getters-setters.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
