C# function to return array
You're trying to return variable Labels
of type ArtworkData
instead of array, therefore this needs to be in the method signature as its return type. You need to modify your code as such:
public static ArtworkData[] GetDataRecords(int UsersID){ ArtworkData[] Labels; Labels = new ArtworkData[3]; return Labels;}
Array[]
is actually an array of Array
, if that makes sense.
return Labels;
should do the trick!
public static ArtworkData[] GetDataRecords(int UsersID){ ArtworkData[] Labels; Labels = new ArtworkData[3]; return Labels;}
public static ArtworkData[] GetDataRecords(int UsersID){ ArtworkData[] Labels; Labels = new ArtworkData[3]; return Labels;}
This should work.
You only use the brackets when creating an array or accessing an array. Also, Array[]
is returning an array of array. You need to return the typed array ArtworkData[]
.