NPetrovich 1.2.0

.NET Framework 4.0
Install-Package NPetrovich -Version 1.2.0
dotnet add package NPetrovich --version 1.2.0
<PackageReference Include="NPetrovich" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NPetrovich --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NPetrovich, 1.2.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install NPetrovich as a Cake Addin
#addin nuget:?package=NPetrovich&version=1.2.0

// Install NPetrovich as a Cake Tool
#tool nuget:?package=NPetrovich&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

NPetrovich is library which inflects Russian names to given grammatical case. It supports first names, last names and middle names inflections.

NPetrovich is C#/.NET implementation of Petrovich ruby gem.

Build status



PM> Install-Package NPetrovich


Just reference NPetrovich dll to your project.


Run psake.ps1 script with Powershell to build solution. You can find output binaries in the bin directory.


Basic usage

var petrovich = new Petrovich()
		FirstName = "Иван",
		LastName = "Иванов",
		MiddleName = "Иванович",
		Gender = Gender.Male

// Inflect all properties
var inflected = petrovich.InflectTo(Case.Dative);

System.Console.WriteLine(inflected.FirstName); // Ивану
System.Console.WriteLine(inflected.LastName); // Иванову
System.Console.WriteLine(inflected.MiddleName); // Ивановичу

inflected = petrovich.InflectTo(Case.Instrumental);

System.Console.WriteLine(inflected.FirstName); // Иваном
System.Console.WriteLine(inflected.LastName); // Ивановым
System.Console.WriteLine(inflected.MiddleName); // Ивановичем

// Inflect each property
System.Console.WriteLine(petrovich.InflectFirstNameTo(Case.Genitive)); // Ивана
System.Console.WriteLine(petrovich.InflectLastNameTo(Case.Genitive)); // Иванова
System.Console.WriteLine(petrovich.InflectMiddleNameTo(Case.Genitive)); // Ивановича

You can use automatic gender detection based on middle name or first and last names, if the middle name not determinates gender:

var petrovich = new Petrovich()
        FirstName = "Иван",
        LastName = "Иванов",
        MiddleName = "Иванович",
        AutoDetectGender = true

System.Console.WriteLine(petrovich.Gender); // Male

Also you can use GenderUtils to detect gender based on middle name:

Gender gender = GenderUtils.Detect("Иванович");
System.Console.WriteLine(gender); // Male

Advanced usage

You can use your own rules loader which implements IRulesLoader interface:

IRulesLoader customLoader = new CustomRulesLoader();
var petrovich = new Petrovich(customLoader);
Product Versions
.NET Framework net40 net403 net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 4,427 5/31/2018
1.1.0 916 1/22/2017
1.0.1 2,876 7/11/2014