💎 Some util C# code snippets
How about getting a few handy code snippets for your C# project?
In lots of my projects, I reuse some basic utilities over and over again: picking an item from a collection at random, initialising an array with all the ints up to a given number, shuffling a list…
So, today, I’ve decided to share a little list of handy snippets that you could be useful to you! :)
Quick data manipulation
Snippet #1: Creating an array of integers from 0 to N
Oftentimes, I’m looking for ways to make my arrays initialisation phase easier. Because if you don’t want for an array filled with zeros to start with but instead you want some specific values, most of the time you’ll be forced to iterate the array and do the initialisation yourself.
A special case though is if you want your array to count up to a given integer N; here, you can make use of the Enumerable
type: