Skip to content

Instantly share code, notes, and snippets.



Last active Oct 16, 2019
What would you like to do?
Provide c# decimal datatype for gRPC (based on
using System.Linq;
public partial class DecimalValue
public DecimalValue(int[] bits) => Bits.AddRange(bits);
public static implicit operator decimal(DecimalValue decimalValue) => decimalValue.ToDecimal();
public static implicit operator DecimalValue(decimal value) => FromDecimal(value);
public decimal ToDecimal() => new decimal(Bits.ToArray());
public static DecimalValue FromDecimal(decimal value) => new DecimalValue(decimal.GetBits(value));
// Name "DecimalValue" prevents conflict with C# Decimal type
message DecimalValue {
repeated int32 bits = 1;

This comment has been minimized.

Copy link
Owner Author

@RobThree RobThree commented Oct 16, 2019

See for good reason NOT to use this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment