Home > Blockchain >  When trying to append a FormFile to a FormFile[] (array) the FormFile is null
When trying to append a FormFile to a FormFile[] (array) the FormFile is null

Time:10-22

I have a FormFile[] that when I try adding a non-null FormFile object to it the array does not show any values.

     FormFile[] fileArray = new FormFile[10];
     FormFile myFile = new FormFile( /*Excel File*/ );
     fileArray.Append(myFile);

myFile[0] = null

CodePudding user response:

If you are using System.Linq.Append this will return an new array with the value added at the end.
If you do the following:

 FormFile[] fileArray = new FormFile[10];
 FormFile myFile = new FormFile( /*Excel File*/ );
 var newFileArray = fileArray.Append(myFile);

newFileArray[11] will contain myFile

  • Related