c# RSS

Follow The Programmer Blog RSS feed to stay up to date with the latest programming tutorials regarding anything c#. If you're looking to upgrade your software developer shirt collection we offer some pretty cool programmer shirts. For more of the latest developer news and programming tutorials visit The Programmer Blog. View all programming tutorials tagged with c# below:

c#, generic

C# - Calling a generic method

First I'd like to say Happy New Year! I hope that everyone had a good time celebrating NYE 2017. Now let's move onto the fun stuff in 2018, programming! I have been seeing a lot of questions about how to call generic methods using reflection in C# so that will be the topic at focus. Calling generic methods in C#...

Read more

c#, c# outofmemoryexception, exception, outofmemory, system.outofmemoryexception c#, systemoutofmemory

C# - Out of Memory Exception

C# System.OutOfMemoryException While programming for my web app the other day, my application threw an System.OutOfMemoryException when initializing a list of objects. To me this seemed pretty much impossible because my machine has 4GB RAM. Specifically the error happened when I tried to add an existing collection to a new list. For example: List newShapes = new List(selectedShapes); My original thought...

Read more

c#, list, random

C# - Randomizing a List<T>

Randomizing a list<T> can be done using the Random and a simple LINQ query. Check out our card shuffling example below: Randomizing a list of objects Given a Card class public class Card { public string Name { get; set; } public int Value { get; set; } } Initialize a new list of cards var cards = new List<Card>()...

Read more

c#, c# enum to int, c# int to enum, cast, enum, int, string

C# - Cast int to enum

Casting enums can get tricky in C# so we wanted to provide a few examples to help clarify the situation. Below we are using a simple enum to demonstrate how to cast an int to a enum, enum to an int. We will also go over how to check if an enum exists given an integer or string and how to...

Read more