Number Extensions
Extensions to numeric data types such as: int, double, decimal, byte...

IsEven

Determines whether the given number is even.

                        bool IsEven(this int source);Example:
                        bool result = 2.IsEven(); // true  
bool result = 1.IsEven(); // false 
                    

IsOdd

Determines whether the given number is odd.

                        bool IsOdd(this int source);Example:
                        bool result = 2.IsOdd(); // false  
bool result = 1.IsOdd(); // true 
                    

IsGreaterThan

Determines whether the current number is greater than the target one.

                        bool IsGreaterThan(this int source, int target);Example:
                        bool result = 2.IsGreaterThan(3); // false  
bool result = 3.IsGreaterThan(1); // true 
                    

IsLessThan

Determines whether the current number is less than the target one.

                        bool IsLessThan(this int source, int target);Example:
                        bool result = 2.IsLessThan(1); // false  
bool result = 3.IsLessThan(4); // true 
                    

IsEqualTo

Determines whether the current number is equal to the target one.

                        bool IsEqualTo(this int source, int target);Example:
                        bool result = 2.IsEqualTo(1); // false  
bool result = 3.IsEqualTo(3); // true 
                    

DaysAgo

Gets the datetime in past from given number of days.

                        DateTime DaysAgo(this int days);Example:
                        DateTime result = 2.DaysAgo();
DateTime result = 3.DaysAgo(); 
                    

DaysAfter

Gets the datetime in future from given number of days.

                        DateTime DaysAfter(this int days);Example:
                        DateTime result = 2.DaysAfter();
DateTime result = 3.DaysAfter(); 
                    

WeeksAgo

Gets the datetime in past from given number of weeks.

                        DateTime WeeksAgo(this int weeks);Example:
                        DateTime result = 2.WeeksAgo();
DateTime result = 3.WeeksAgo(); 
                    

WeeksAfter

Gets the datetime in future from given number of weeks.

                        DateTime WeeksAfter(this int weeks);Example:
                        DateTime result = 2.WeeksAfter();
DateTime result = 3.WeeksAfter(); 
                    

MonthsAgo

Gets the datetime in past from given number of months.

                        DateTime MonthsAgo(this int months);Example:
                        DateTime result = 2.MonthsAgo();
DateTime result = 3.MonthsAgo(); 
                    

MonthsAfter

Gets the datetime in future from given number of months.

                        DateTime MonthsAfter(this int months);Example:
                        DateTime result = 2.MonthsAfter();
DateTime result = 3.MonthsAfter(); 
                    

YearsAgo

Gets the datetime in past from given number of years.

                        DateTime YearsAgo(this int years);Example:
                        DateTime result = 2.YearsAgo();
DateTime result = 3.YearsAgo(); 
                    

YearsAfter

Gets the datetime in future from given number of years.

                        DateTime YearsAfter(this int years);Example:
                        DateTime result = 2.YearsAfter();
DateTime result = 3.YearsAfter(); 
                    

Days

Converts the given number into days.

                        DateTime Days(this int num);Example:
                        DateTime result = 2.Days();
DateTime result = 3.Days(); 
                    

IsLeapYear

Determines whether the given year is a leap year.

                        bool IsLeapYear(this int year);Example:
                        bool result = 2020.IsLeapYear(); // true
bool result = 2021.IsLeapYear(); // false
                    

PreviousLeapYear

Gets the previous leap year based on the given year.

                        int PreviousLeapYear(this int year);Example:
                        DateTime result = 2021.PreviousLeapYear();
DateTime result = 2020.PreviousLeapYear(); 
                    

NextLeapYear

Gets the next leap year based on the given year.

                        int NextLeapYear(this int year);Example:
                        DateTime result = 2019.NextLeapYear(); // 2020
DateTime result = 2021.NextLeapYear(); // 2024 
                    

FromByeArrayToBase64

Converts byte array to base64 string.

                        string FromByeArrayToBase64(this byte[] source, Base64FormattingOptions options = Base64FormattingOptions.None);Example:
                        byte[] byteArray = "FluentExtensions".GetBytes(); // GetBytes() also exits in this library.
string result = byteArray.FromByeArrayToBase64(); 
                    

SeparateThousandsByComma

Separates every 3 number by comma.

                        string SeparateThousandsByComma(this int source);Example:
                        string result = 23459.SeparateThousandsByComma(); // "23,459"
string result = 1589324.SeparateThousandsByComma(); // "1,589,324" 
                    

SeparateThousandsByComma

Separates every 3 number by comma.

                        string SeparateThousandsByComma(this int source, CultureInfo culture);Example:
                        CultureInfo culture = new CultureInfo("en-US");
string result = 1589324.SeparateThousandsByComma(culture); // "1,589,324" 
                    

RandomDigits

Generating Random Numbers.

                        string RandomDigits(this int length);Example:
                        string result = 4.RandomDigits();
string result = 6.RandomDigits();  
                    

GenerateRandomString

Generating Random Strings.

                        string GenerateRandomString(this int length, bool isUpperCase = false, bool containNumbers = false);Example:
                        string result = 4.GenerateRandomString();
string result = 6.GenerateRandomString(isUpperCase: true, containNumbers: true);  
                    

ToKB

Converts given number to kilobytes.

                        double ToKB(this int number, DigitalStorage from = DigitalStorage.KB);Example:
                        double result = 4.ToKB(DigitalStorage.MB);
double result = 6.ToKB(DigitalStorage.GB);  
                    

ToMB

Converts given number to megabytes.

                        double ToMB(this int number, DigitalStorage from = DigitalStorage.MB);Example:
                        double result = 4.ToMB(DigitalStorage.KB);
double result = 6.ToMB(DigitalStorage.GB);  
                    

ToGB

Converts given number to gigabytes.

                        double ToGB(this int number, DigitalStorage from = DigitalStorage.GB);Example:
                        double result = 4.ToGB(DigitalStorage.MB);
double result = 6.ToGB(DigitalStorage.TB);  
                    

ToTB

Converts given number to terabytes.

                        double ToTB(this int number, DigitalStorage from = DigitalStorage.TB);Example:
                        double result = 4.ToTB(DigitalStorage.MB);
double result = 6.ToTB(DigitalStorage.GB);  
                    

ToKB

Converts given number to kilobytes.

                        double ToKB(this long number, DigitalStorage from = DigitalStorage.KB);Example:
                        double result = 4.ToKB(DigitalStorage.MB);
double result = 6.ToKB(DigitalStorage.GB);  
                    

ToMB

Converts given number to megabytes.

                        double ToMB(this long number, DigitalStorage from = DigitalStorage.MB);Example:
                        double result = 4.ToMB(DigitalStorage.KB);
double result = 6.ToMB(DigitalStorage.GB);  
                    

ToGB

Converts given number to gigabytes.

                        double ToGB(this long number, DigitalStorage from = DigitalStorage.GB);Example:
                        double result = 4.ToGB(DigitalStorage.MB);
double result = 6.ToGB(DigitalStorage.TB);  
                    

ToTB

Converts given number to terabytes.

                        double ToTB(this long number, DigitalStorage from = DigitalStorage.TB);Example:
                        double result = 4.ToTB(DigitalStorage.MB);
double result = 6.ToTB(DigitalStorage.GB);