CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2000
    Posts
    64

    How to initialize a struct

    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

  2. #2
    Join Date
    Oct 2001
    Location
    Norway
    Posts
    265
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured