Click to See Complete Forum and Search --> : How to initialize a struct


Leo Ayala
November 2nd, 2002, 01:03 AM
What is the best way to initialize a struct to a specific value. For example, in C++, I was able to use ZeroMemory(...), or memset. Are there any similar methods in C#?

LA

Arild Fines
November 2nd, 2002, 05:22 AM
Any primitive members in a C# struct will automatically be set to their default value - usually 0. If you have other needs, you must define a constructor that takes at least one argument and do your initialization in there.