Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
IComparable extensions: Between
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using IComparableExtensions; namespace Rextester { public class Program { public static void Main(string[] args) { if(5.Between(5, 7, CompareMode.Inclusive)) Console.WriteLine("Hello, world!"); } } } namespace IComparableExtensions { [Flags] public enum CompareMode { Exclusive = 0, IncludeLow = 1, IncludeHigh = 2, Inclusive = IncludeLow | IncludeHigh } public static class IComparableExtensions { public static bool Between<T>(this T self, T low, T high, CompareMode mode) where T : IComparable { var compareLow = (mode & CompareMode.IncludeLow) == CompareMode.IncludeLow ? 0 : 1; var compareHigh = (mode & CompareMode.IncludeHigh) == CompareMode.IncludeHigh ? 0 : -1; return self.CompareTo(low) >= compareLow && self.CompareTo(high) <= compareHigh; } } }
run
|
edit
|
history
|
help
0
Free v Bucks Codes
newMultQ working on more2
bytes to string to bytes.
Boggle
Việc Làm Bắc Ninh
eu odeio minha vida
Sort string collection by length
Namespace addition
sgshdfhdfhfdh
test