This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace StackOverflow | |
{ | |
class Program | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Pathy | |
{ | |
public static string Combine(string path1, string path2) | |
{ | |
if (path1 == null) return path2 | |
else if (path2 == null) return path1 | |
else return path1.Trim().TrimEnd(System.IO.Path.DirectorySeparatorChar) | |
+ System.IO.Path.DirectorySeparatorChar | |
+ path2.Trim().TrimStart(System.IO.Path.DirectorySeparatorChar); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Unit | |
{ | |
public string Item { get; set; } | |
public int Weight { get; set; } | |
} | |
public class Program | |
{ | |
public static Unit GetWeightedRandomNumber(List<Unit> list) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void CalculateAge(DateTime dt1, DateTime dt2, out int years, out int months, out int days) | |
{ | |
DateTime start = dt1 < dt2 ? dt1 : dt2; | |
DateTime end = dt2 > dt1 ? dt2 : dt1; | |
years = 0; | |
months = 0; | |
days = 0; | |
while (start.AddYears(1) < end) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class EnumHelper<T> | |
{ | |
public static string GetEnumDescription(string value) | |
{ | |
Type type = typeof(T); | |
var name = Enum.GetNames(type).Where(f => f.Equals(value, StringComparison.CurrentCultureIgnoreCase)).Select(d => d).FirstOrDefault(); | |
if (name == null) | |
{ | |
return string.Empty; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
// SO Link 1 : https://stackoverflow.com/a/263416/302248 | |
// SO Link 2 : https://stackoverflow.com/q/45601078/302248 | |
namespace ComparerGetHashCode | |
{ | |
public class NumberClass | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static string InsertThousandsSeparator(string input) | |
{ | |
var dec = decimal.Parse(input); | |
var bits = decimal.GetBits(dec); | |
var prec = bits[3] >> 16 & 255; | |
return dec.ToString("N" + prec); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
using System.Windows; | |
using System.Windows.Interop; | |
namespace KawasakiLogConverter | |
{ | |
/// <summary> | |
/// Interaction logic for ProgressBarWindow.xaml | |
/// </summary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.ComponentModel; | |
using System.Threading; | |
using System.Windows; | |
namespace WPFProgressBar | |
{ | |
/// <summary> | |
/// Interaction logic for MainWindow.xaml | |
/// </summary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// (1 = A, 2 = B...27 = AA...703 = AAA...) | |
public static string GetColNameFromIndex(int columnNumber) | |
{ | |
int dividend = columnNumber; | |
string columnName = String.Empty; | |
int modulo; | |
while (dividend > 0) | |
{ | |
modulo = (dividend - 1) % 26; |
NewerOlder