Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- [Serializable]
- public class FancyRange<T> where T : IComparable
- {
- public T Min;
- public T Max;
- public FancyRange()
- {
- Min = default;
- Max = default;
- }
- public FancyRange(T min, T max)
- {
- Min = min;
- Max = max;
- }
- public virtual bool Contains(T val)
- {
- return val.CompareTo(Min) >= 0 && val.CompareTo(Max) <= 0;
- }
- public override string ToString()
- {
- return "(" + Min + ", " + Max + ")";
- }
- }
- [Serializable]
- public class FancyIntRange : FancyRange<int>
- {
- public FancyIntRange() : base() { }
- public FancyIntRange(int min, int max) : base(min, max) { }
- }
- [Serializable]
- public class FancyFloatRange : FancyRange<float>
- {
- public FancyFloatRange() : base() { }
- public FancyFloatRange(float min, float max) : base(min, max) { }
- }
- [Serializable]
- public class FancyDoubleRange : FancyRange<double>
- {
- public FancyDoubleRange() : base() { }
- public FancyDoubleRange(double min, double max) : base(min, max) { }
- }
- [Serializable]
- public class FancyLongRange : FancyRange<long>
- {
- public FancyLongRange() : base() { }
- public FancyLongRange(long min, long max) : base(min, max) { }
- }
- [Serializable]
- public class FancyShortRange : FancyRange<short>
- {
- public FancyShortRange() : base() { }
- public FancyShortRange(short min, short max) : base(min, max) { }
- }
- [Serializable]
- public class FancySByteRange : FancyRange<sbyte>
- {
- public FancySByteRange() : base() { }
- public FancySByteRange(sbyte min, sbyte max) : base(min, max) { }
- }
- [Serializable]
- public class FancyByteRange : FancyRange<byte>
- {
- public FancyByteRange() : base() { }
- public FancyByteRange(byte min, byte max) : base(min, max) { }
- }
- [Serializable]
- public class FancyUShortRange : FancyRange<ushort>
- {
- public FancyUShortRange() : base() { }
- public FancyUShortRange(ushort min, ushort max) : base(min, max) { }
- }
- [Serializable]
- public class FancyUIntRange : FancyRange<uint>
- {
- public FancyUIntRange() : base() { }
- public FancyUIntRange(uint min, uint max) : base(min, max) { }
- }
- [Serializable]
- public class FancyULongRange : FancyRange<ulong>
- {
- public FancyULongRange() : base() { }
- public FancyULongRange(ulong min, ulong max) : base(min, max) { }
- }
- [Serializable]
- public class FancyDecimalRange : FancyRange<decimal>
- {
- public FancyDecimalRange() : base() { }
- public FancyDecimalRange(decimal min, decimal max) : base(min, max) { }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement