c# - Array objects of calls are set to NULL and not set to constructor values -
This question is already an answer here
- 28 replies
I have a Class is a string of names like id, id, last name, public are the automatic properties and for this, I have defined a constructor for it and in the form of them as
string.Empty
Also defined. Now in the code I create an array of this class like this:
AlternateAddressSummary [] alternateAddressSummaries = new AlternateAddressSummary [6]; Int adrsCounter = -1; Foreign Language (Address Address Address- Optional) {adrsCounter ++; Fill AlignAttressSmurridge (Optional Aspersor Schmidars [Edscontor], Eders); }
and FillAlternateAddressSummaryObject
simply fill the properties of each object for example:
Private Zero FillAlternateAddressSummaryObject (AlternateAddressSummary Ala, Address Adrs) {alA.AlternateAdressLine1 = adrs.City; // ...}
but why do I get an exception ala
at NULL
? Even when I create those 6 array objects, they are started on NULL
. Should they not be set to say in constructor
I Because there was no instance of any of your members alternateAddressSummaries
what you have done is kind of like this
AlternateAddressSummary1; AlternateAddressSummary2; AlternateAddressSummary3; ...
You have declared the AlternateAddressSummary
array , but you have not actually instantiated any of them. They are still doing all null
You did that if it was for
(int i = 0; i & Lt; alternateAddressSummaries.Length; I ++) {Optional Address Summiters [i] = New Alternative Academy (/ * Parameters / /); }
These will be done promptly and whatever their value will be set by your conservator.
Comments
Post a Comment