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
| //<sumary> | |
| //Sample Usage of the StartupController class | |
| //</sumary> | |
| static class Program | |
| { | |
| [STAThread] | |
| static void Main() | |
| { | |
| StartupController startupController = new StartupController(); | |
| startupController.RunOnce<MainForm>(); |
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
| Dim random As New Random() | |
| ... | |
| Dim randomDouble As Double = | |
| Math.Round((random.NextDouble() * 6), 2) |
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
| private static bool PortAvailableForListening(int portNumber) | |
| { | |
| IPEndPoint[] activeTcpListeners = IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners(); | |
| return activeTcpListeners.Select(x => x.Port == portNumber).FirstOrDefault(); | |
| } |
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 Delegate Function ToInt32Proxy(ByVal value As Char) As Integer | |
| .. | |
| Dim someDelegate = | |
| [Delegate].CreateDelegate(GetType(ToInt32Proxy), GetType(Convert).GetMethod("ToInt32", New Type() {GetType(Char)})) | |
| Dim someProxy = DirectCast(someDelegate, ToInt32Proxy) | |
| Dim someValue = someProxy("a") |
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
| internal static IEnumerable<T> ToEnumerableOf<T>(this Enum theEnum) | |
| { | |
| return Enum.GetValues(theEnum.GetType()).Cast<T>(); | |
| } |
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 Program | |
| { | |
| private static readonly Random _random = new Random(); | |
| private static void Main() | |
| { | |
| foreach (int randomNumber in GetRandomNumbers(10)) | |
| Console.WriteLine(randomNumber); | |
| Console.ReadKey(); |
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
| Imports System.Web.Script.Serialization | |
| Module Program | |
| Sub Main() | |
| Const jsonResponse = "{""a"":1,""b"":2,""c"":3,""d"":4,""e"":5}" | |
| Dim serializer As New JavaScriptSerializer() | |
| Dim response As Response = serializer.Deserialize(Of Response)(jsonResponse) |
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
| git remote -v #output remotes | |
| git remote rm REMOTENAME #remove remote | |
| git add -A #include deleted files | |
| git commit -am "message" #add and commit at the same time | |
| rm -rf .git #Remove git init | |
| ===UniX Hecks |
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
| //data source | |
| string[] names = { "ByteBlast", "Shockwave2", "Salmoneus", "Banksy" }; | |
| //query syntax | |
| var names1 = | |
| from name in names | |
| where name.StartsWith("B") | |
| select name; | |
| //compiler translates the above into :- |
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
| private static IEnumerable<string> LoadNames() | |
| { | |
| string names =File.ReadAllText("names.txt"); | |
| return names.Split(',') | |
| .Select(name => name.Substring(1, name.Length - 2)); | |
| } | |
| private static int CalculateTotalScore() | |
| { | |
| return LoadName().OrderBy(x => x) |
OlderNewer