Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 通过成员函数传递数组,并使用其值设置一个新数组(以F为单位)#_Arrays_Class_F#_Copy_Member - Fatal编程技术网

Arrays 通过成员函数传递数组,并使用其值设置一个新数组(以F为单位)#

Arrays 通过成员函数传递数组,并使用其值设置一个新数组(以F为单位)#,arrays,class,f#,copy,member,Arrays,Class,F#,Copy,Member,代码: 开放系统 开放系统.Net 开放系统 键入Student(x:string,y:int[])=class 设可变id=x 设可变分数=y new()=学生(“,[|-1;-1;-1;-1;-1;-1;-1 |]) 成员this.setScores(a:int[] 分数=数组。复制a 成员this.setId(s:string)= id新学生()|] 学生[0].setId(“c1234501”) 学生[0]。设置分数([|10;20;10;30;30 |]) 所以我有这个类,我需要能

代码:

开放系统
开放系统.Net
开放系统
键入Student(x:string,y:int[])=class
设可变id=x
设可变分数=y
new()=学生(“,[|-1;-1;-1;-1;-1;-1;-1 |])
成员this.setScores(a:int[]
分数=数组。复制a
成员this.setId(s:string)=
id新学生()|]
学生[0].setId(“c1234501”)
学生[0]。设置分数([|10;20;10;30;30 |])

所以我有这个类,我需要能够根据请求将数组分数设置为数组I
传递给成员函数。我尝试过分数之类的方法,您的
设置分数
成员应该是:

 open System
 open System.Net
 open System.IO

 type Student(x:string, y:int[]) = class

    let mutable id = x
    let mutable scores = y
    new() = Student("", [|-1;-1;-1;-1;-1|])
    member this.setScores(a:int[])
        scores = Array.copy a   
    member this.setId(s:string)=
        id <- s
    member this.getId() =
        id
    member this.getScores() = 
        scores

end

let students = [|for i in 1 .. 30 -> new Student() |]

students.[0].setId("c1234501")
students.[0].setScores([|10; 20; 10; 30; 30|])
成员this.setScores(a:int[]=
分数
member this.setScores(a:int[]) =
    scores <- Array.copy a