Skip to main content
Version: dev

C# Setup

Fory C# provides xlang Object Serialization, generated models, and Fory gRPC. The Apache.Fory NuGet package requires .NET 8 or later and includes both the serialization library and source generator.

Verify the Toolchain

dotnet --version

Object Serialization

Create a console project and add the released package:

dotnet new console -n ForyExample
cd ForyExample
dotnet add package Apache.Fory --version 1.5.0

Replace Program.cs with:

using Apache.Fory;

[ForyStruct]
public sealed class User
{
public long Id { get; set; }
public string Name { get; set; } = string.Empty;
}

public static class Program
{
public static void Main()
{
Fory fory = Fory.Builder().Build();
fory.Register<User>(1);

byte[] bytes = fory.Serialize(new User { Id = 1, Name = "Alice" });
User decoded = fory.Deserialize<User>(bytes);
Console.WriteLine(decoded.Name);
}
}
dotnet run

C# uses xlang mode. Continue with C# Object Serialization, xlang types, configuration, and schema evolution.

Other Capabilities