简体   繁体   中英

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:

  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'
  4. 'Microsoft.Samples.Kinect.SkeletonBasics.MainWindow.lhand' is a 'field' but is used like a 'type'

It sounds like you're trying to call Add outside of a method. 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);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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