0

This is the line of code I am having trouble converting:

Vector3 n1 = m.normals.get((int) face.normal.X - 1);

I am not sure what this translates to in c# as I have tried quite a few things. I think it may also be due to a problem with my lists:

class Model
{
    public List<Vector3> vertices = new List<Vector3>();
    public List<Vector3> normals = new List<Vector3>();
    public List<Face> faces = new List<Face>();

}

They were supposed to be:

class Model
{
    public List<Vector3> vertices = new ArrayList<Vector3>();
    public List<Vector3> normals = new ArrayList<Vector3>();
    public List<Face> faces = new ArrayList<Face>();

}

I dont know what ListArray translates to in c# either.

Any help would be greatly appreciated :)

2
  • 1
    Never heard of ListArray in Java. Is it a proprietory class? Do you mean ArrayList? Commented Apr 28, 2013 at 9:59
  • 1
    ArrayList ? Commented Apr 28, 2013 at 9:59

1 Answer 1

4
Java               C#
------------    --------
List<T>      is IList<T>   // Interface
ArrayList<T> is List<T>    // Class implementing the interface

You can translate your code like this:

class Model
{
    public IList<Vector3> vertices = new List<Vector3>();
    public IList<Vector3> normals = new List<Vector3>();
    public IList<Face> faces = new List<Face>();
}

Java's get becomes C#'s indexer, so

Vector3 n1 = m.normals.get((int) face.normal.X - 1);

becomes

Vector3 n1 = m.normals[(int)face.normal.X - 1];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.