我有buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
付款对象包括:
DateTime PaymentDate;十进制数量;
我需要做的是创建一个最终结果如下的数组:
List<PaymentObject>
如何通过我的列表进行操作,并将每个项目添加到数组?
答案 0 :(得分:2)
一种方式可能如下:
var paymentObjectList = new List<PaymentObject>();
// assuming the above gets populated at some point
object[,] dataArray = new object[paymentObjectList.Count, 2];
int listIndex = 0;
foreach (var paymentObject in paymentObjectList)
{
dataArray[listIndex, 0] = paymentObject.PaymentDate;
dataArray[listIndex, 1] = paymentObject.Amount;
listIndex++;
}
// resuming your original code
s.Data = new Data(dataArray);