💎 Some util C# code snippets

How about getting a few handy code snippets for your C# project?

Mina Pêcheux
C# Programming

--

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…

Photo by Muha Ajjan on Unsplash

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:

--

--

Mina Pêcheux
C# Programming

I’m a freelance full-stack web & game developer. I’m passionate about topics like CGI, music, data science and more! Find me at: https://minapecheux.com :)