Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
code_snippets:csharp_snippets [2014/06/17 18:15] – smark | code_snippets:csharp_snippets [2014/06/19 16:19] (current) – smark | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== C# Snippets ====== | ====== C# Snippets ====== | ||
+ | === string CombineAfterIndex(string[] InputArr, string Glue, int StartIdx) === | ||
+ | Combine elements of a string array with a string between them, after an index from the first array | ||
<code c#> | <code c#> | ||
public static string CombineAfterIndex(string[] InputArr, string Glue, int StartIdx) { | public static string CombineAfterIndex(string[] InputArr, string Glue, int StartIdx) { | ||
Line 10: | Line 12: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | === List< | ||
+ | |||
<code c#> | <code c#> | ||
public static List< | public static List< | ||
Line 34: | Line 39: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | === int OccurrencesInString(String Haystack, String Needle) === | ||
+ | Counts the number of occurrences of Needle in Haystack. | ||
<code c#> | <code c#> | ||
/// < | /// < | ||
- | /// Counts the number of occurances | + | /// Counts the number of occurrences |
/// </ | /// </ | ||
/// <param name=" | /// <param name=" | ||
/// <param name=" | /// <param name=" | ||
/// < | /// < | ||
- | public static int OccurancesInString(String Haystack, String Needle) { | + | public static int OccurrencesInString(String Haystack, String Needle) { |
return Regex.Matches(Haystack, | return Regex.Matches(Haystack, | ||
} | } | ||
</ | </ | ||
+ | === void PrintArrayList(ArrayList InputArray) === | ||
+ | Prints an ArrayList object to the console. | ||
<code c#> | <code c#> | ||
/// < | /// < | ||
Line 59: | Line 69: | ||
</ | </ | ||
+ | === void DumpByteArrayToFile(byte[] inputBytes, String FileName) === | ||
+ | Dumps a byte[] Array to a file. | ||
<code c#> | <code c#> | ||
/// < | /// < | ||
Line 75: | Line 87: | ||
</ | </ | ||
+ | === void DumpStringToFile(String inputString, | ||
+ | Dumps a String to a file. | ||
<code c#> | <code c#> | ||
/// < | /// < | ||
Line 91: | Line 105: | ||
</ | </ | ||
+ | === void PrintCharArrASCII(char[] inputCharArr) === | ||
+ | Prints the ASCII values of every character in a character array delimited by a pipe character to the Console. | ||
<code c#> | <code c#> | ||
/// < | /// < | ||
Line 105: | Line 121: | ||
</ | </ | ||
+ | === void PrintStringASCII(String inputStr) === | ||
+ | Prints the ASCII values of every character in a string delimited by a pipe character to the Console. | ||
<code c#> | <code c#> | ||
/// < | /// < | ||
Line 120: | Line 138: | ||
</ | </ | ||
+ | === void PrintByteArrASCII(byte[] inputByteArr) === | ||
+ | Prints the ASCII values of every character in a character array delimited by a pipe character to the Console. | ||
<code c#> | <code c#> | ||
/// < | /// < | ||
Line 134: | Line 154: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | === ByteArrToASCII(byte[] inputByteArr) === | ||
<code c#> | <code c#> | ||
Line 146: | Line 168: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | === String RemoveNewLineChars(String inputStr) === | ||
<code c#> | <code c#> | ||
Line 160: | Line 184: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | === String StringArrToDelimitedStr(String[] inputStrArr, | ||
<code c#> | <code c#> | ||
Line 179: | Line 205: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | === String BytesToHumanReadable(long Bytes, int Accuracy) === | ||
<code c#> | <code c#> | ||
Line 197: | Line 225: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | === String MillisecondsToClockFormat(double Milliseconds) === | ||
<code c#> | <code c#> | ||
Line 213: | Line 243: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | === String MillisecondsToHumanReadable(double Milliseconds) === | ||
<code c#> | <code c#> |