Can I assign a suffix to my custom value type?

c#, struct, value-type

Solution

You can't assign custom suffixes with C#. The closest thing you can do is creating extension method for integers:

public static Money Para(this int value) // you can do same for decimals
{
   return (Money)((decimal)value);
}

Usage:

var amount = 200.Para();

Problem

For money I am using a custom value type which holds only one `decimal` field. Simplified code is as follows. ``` public struct Money { private decimal _value; private Money(decimal money) { _value = Math.Round(money, 2, MidpointRounding.AwayFromZero); } public static implicit operator Money(decimal money) { return new Money(money); } public static explicit operator decimal(Money money) { return money._value; } } ``` While using this struct in my project sometimes an ambiguity arises. And also sometimes I am setting an `object` with a constant number which is supposed to be a `Money`. For now I am initializing the object like, ``` object myObject=(Money)200; ``` Can I assign a suffix for my custom type `Money`. I'd like to initialize the object with the following. ``` object myObject=200p; ```

Original source