简体   繁体   English

不在C#中工作的数组列表

[英]List of Arrays not working in C#

double[] lhand = new double[3] { 0, 0, 0 };

List<double[]> LADC = new List<double[]>(); 

LADC.Add(lhand);

I cant understand why this code above isn't working. 我不明白为什么上面的代码不起作用。 I followed instructions given by questions here in StackOverflow but i ve got the following errors: 我按照StackOverflow中的问题给出了说明但是我有以下错误:

  1. Invalid token '(' in class, struct, or interface member declaration 无效的标记'('在类,结构或接口成员声明中
  2. Invalid token ')' in class, struct, or interface member declaration 类,结构或接口成员声明中的标记')'无效
  3. 'Microsoft.Samples.Kinect.SkeletonBasics.MainWindow.LADC' is a 'field' but is used like a 'type' 'Microsoft.Samples.Kinect.SkeletonBasics.MainWindow.LADC'是'字段',但用作“类型”
  4. 'Microsoft.Samples.Kinect.SkeletonBasics.MainWindow.lhand' is a 'field' but is used like a 'type' 'Microsoft.Samples.Kinect.SkeletonBasics.MainWindow.lhand'是'字段',但用作“类型”

It sounds like you're trying to call Add outside of a method. 听起来你正试图在方法之外调用Add Try to place this in a constructor or method: 尝试将其放在构造函数或方法中:

public class MyClass {
    double[] lhand = new double[3] { 0, 0, 0 };
    List<double[]> LADC = new List<double[]>(); 

    public MyClass() {
        LADC.Add(lhand);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM