Adventures with #12in23 - C#


My first foray into statically typed languages C# seems rather gracious even to the beginner user. 

The Exercism readme files provide you with information required to complete the exercises with very little outside resources needed. My knowledge from other languages also was far more applicable here. Coming from BASH this was a pleasant change of pace, gotta get a whiff of the god complex before stumbling down to impostor syndrome again. Ah the vicious cycle of problem solving.

I also have to admit, I did derive a sense of perverse pleasure from running .net on a Mac.

On implementation note as far as the 5 exercises go there were a few things I’ve found interesting!

To generate a random number we have to instantiate a System.Random class (or as I’ve found out later, just Random, System is implied)
random_csharp.png 70.1 KB

We can see in the example above that there are different methods for both Integers and Doubles!

Switch statements also look funky but the way they accept conditions is weirdly elegant (to me!)

random_csharp.png 70.1 KB

Overall I have to say I’ve found the strongly typed c# refreshing. The general knowledge from outside translated rather well and I’ve felt bold enough to skip a few dozens steps ahead and try a “medium” difficulty exercise.

This was interesting, and I think I’ll try doing that sooner for other tracks where I feel capable. I might have driven head first into a brick wall of trying to raise BigIntegers to the power of other BigIntegers potentially imploding my apartment building. But… Don’t tell anyone. I did also have a lot of fun trying to figure it out, and when I couldn’t, I had fun figuring out why the working solution works. 

bitshifting_csharp.png 91.8 KB

Converting my Big prime into an array of bytes and then generating random numbers with the same number of bytes kind of blew my mind in its simplicity, as did ensuring the sign byte is positive. 

Overall I’m starting to see a trend here and we’re just two languages in, this really seems like it will be a whole lot of fun.  


This website uses cookies to only make you click ok here once. It doesn't collect personal data (and neither do I)