Skip to main content

Posts

Showing posts from February, 2018

Check Statements in .NET

Anytime a C# expression (I presume the same goes for VB) contains a non-constant value, the compiler will not check for out-of-bounds values. For example, if you initialize an integer as the sum of two values, one of which is outside the bounds for integers (-2,147,483,648 to 2,147,483,647), a runtime overflow exception will be generated, but not a compile error. Apparently checking for out-of-bounds values is computationally intensive and most of the time simply isn't worth the time/energy. However, if it is critical that your application generate a compile error for out-of-bounds values, you can use the checked keyword, which is actually classified as a primary operator in C# by Microsoft. You can put checked() around a statement you know might cause an overflow exception or checked{} around a block of code. You can also create a CheckedMethod() or if you want to explicitly avoid overflow checking, use the unchecked keyword or use UncheckedMethod() . Check (pun intended...

Merging Files into a Single .NET Assembly

.NET assemblies can be single-file or multifile.   As I've been preparing to take Microsoft Exam 70-483, I came across the Al.exe command, a tool which is installed along with Visual Studio. Al stands for "Assembly Linker" and when you run it, it "links" different manifest or resource files together into a single assembly. If you work with .NET at all, you probably have a pretty good idea of what an assembly is, but here's a simple definition from Stack Overflow : "A chunk of (precompiled) code that can be executed by the .NET runtime environment. A .NET program consists of one or more assemblies." -Adrian Grigore Here's a more technical definition from Wikipedia :  "A compiled code library used for deployment, versioning, and security."  Normally when you create a new project in Visual Studio, VS pretty much creates the assembly for you. You don't have to worry about merging different files together using the c...

Programming in R

Image saved from my new ShinyApp Over the past few days I've been playing around with R, a statistical language which is essentially an offshoot of S, which was created in the 1980's. R has some powerful features which enable to it rapidly create meaningful graphical illustrations. I've really enjoyed manipulating some of the datasets on Kaggle with it. Here's a ShinyApp I published to demonstrate a simple R program to track where different plant and animal species live within the US national parks.