Skip to content

Instantly share code, notes, and snippets.

@booyaa
Last active January 3, 2016 13:49
Show Gist options
  • Save booyaa/8472404 to your computer and use it in GitHub Desktop.
Save booyaa/8472404 to your computer and use it in GitHub Desktop.
C# CSharp Magick

###get a random number from a range between 1 and 5

Random random = new Random();
int randomNum = random.Next(1,5);

###hardcode app.config name into binary

System.Configuration.ConfigurationManager.OpenExeConfiguration("YourMam.exe.config");

###image/exe name

Console.WriteLine(System.AppDomain.CurrentDomain.FriendlyName);

if you need full path use this instead

Console.WriteLine(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);

###version/build number

var assembly = System.Reflection.Assembly.GetExecutingAssembly(); 
Console.WriteLine(assembly.GetName().Version.ToString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment