当使用任何类型的Resizable数组时,我无法遍历该数组,f#似乎无法理解我的preDefined类型。 这是一个示例代码:
type someData = {
Entry:string ; id:int }
let datas = new ResizeArray<someData>()
let record1 = {someData.Entry = "hiLo" ;someData.id =1234 }
datas.Add(record1)
let record2 = {someData.Entry = "Lolo" ;someData.id =1224 }
datas.Add(record2)
let record3 = {someData.Entry = "Hihi" ;someData.id =1231 }
datas.Add(record3)
let nameOnly = new ResizeArray<string>()
for entries in datas do
nameOnly.Add(entries.Entry)
答案 0 :(得分:0)
如果您在
中运行示例代码type someData =
{ Entry:string ; id:int }
let datas = new ResizeArray<someData>()
let record1 = {someData.Entry = "hiLo" ;someData.id =1234 }
datas.Add(record1)
let record2 = {someData.Entry = "Lolo" ;someData.id =1224 }
datas.Add(record2)
let record3 = {someData.Entry = "Hihi" ;someData.id =1231 }
datas.Add(record3)
let nameOnly = new ResizeArray<string>()
let createEntries () =
for entries in datas do
nameOnly.Add(entries.Entry)
createEntries()
没有问题。如果您首先输入代码的一部分直到for循环,然后输入for循环,代码也会运行。我认为它与被放入交互式临时模块的类型有关。