.NET Fiddle

CSharp · Console

/Program.cs

using System;
using System.Collections.Generic;
using System.Linq;

Console.WriteLine(A.IntToEnum<Bla>(100));
enum Bla
{
	A = 0,
	B = 100
}

public static class A
{
	public static TEnum IntToEnum<TEnum>(int i)
		where TEnum : Enum
	{
		Array array = Enum.GetValues(typeof(TEnum));
		int[] intValues = (int[])array;
		TEnum[] enumValues = (TEnum[])array;
		var b = intValues.Zip(enumValues);
		//Consider saving the dictionary to avoid recreating each time
		var c = b.ToDictionary<(int n, TEnum e), int, TEnum>(p => p.n, p => p.e);
		return c[i]; //KeyNotFoundException possible here
	}
}
;