# Grain Constructors

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.grain/)

## Grain {#constructor-ff0adb98}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.grain/constructors/constructor-ff0adb98/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/Orleans.Core.Abstractions/Core/Grain.cs#L46-L47)

```csharp
protected Grain()
```

This constructor should never be invoked. We expose it so that client code (subclasses of Grain) do not have to add a constructor. Client code should use the GrainFactory property to get a reference to a Grain.

## Grain(IGrainContext, IGrainRuntime?) {#constructor-orleans-runtime-igraincontext-orleans-runtime-igrainruntime-nullable-9caab11b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.grain/constructors/constructor-orleans-runtime-igraincontext-orleans-runtime-igrainruntime-nullable-9caab11b/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/Orleans.Core.Abstractions/Core/Grain.cs#L54-L60)

```csharp
protected Grain(IGrainContext grainContext, IGrainRuntime? grainRuntime = null)
```

Grain implementers do NOT have to expose this constructor but can choose to do so. This constructor is particularly useful for unit testing where test code can create a Grain and replace the IGrainIdentity and IGrainRuntime with test doubles (mocks/stubs).

### Parameters

- `grainContext` (`IGrainContext`)
- `grainRuntime` (`IGrainRuntime?`)
