Wednesday, July 13, 2011

Setting all elements of an Array to Null in C# (like with memset in C++)

I sometime find it strange that things we take for granted in C++ are hard in C#. Probably I should say hard to find the equivalent for rather than hard to do. I routinely clear out my arrays in C++ with memset (setting each item to 0). To get the equivalent in C#, you can use the Array.Clear(...) method like this:
Here is a more detailed example:

No comments: