Solved

Struct Array Error

Posted on 2004-10-14
1
213 Views
Last Modified: 2010-04-15
Hi

I got  Error when i trying to put Struct Array in another struct    

 Error: cannot have instance field initializers in structs          


                        private struct MyAcount
            {
                  int     InData ;                    
                  int      OutData ;                  
                  int     TotalData ;              
                  bool   EndOfDay  ;                
            }

            

            private struct InOut
            {
                  long  IdEmp ;                    
                  long  Badge  ;                  
                  MyAcount[] InOutAll  = new MyAcount[5] ;
                  string DayNum  ;              
                  long   DayAll ;                
            }

            
0
Comment
Question by:Kobi55
1 Comment
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 12306417
Such initrialization is impossible because structure must be allocated on stack. To get the functionality you want convert structure to class.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now