C# Arrays

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jandeerit
    New Member
    • Sep 2008
    • 12

    C# Arrays

    Hi,

    I have the following data..

    RefX[0] = 10;
    RefY[0] = 11;
    RefX[1] = 20;
    RefY[1] = 22;
    RefX[2] = 30;
    RefY[2] = 33;

    int[] ref = new int[6];

    I want to store these values inside ref where the resulting array would be {10,11,20,22,30 ,33}.

    How should I do it? Suggestions please...

    Thanks..
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Well, one big problem is that "ref" is a reserved word. It can't be used for variable names.

    Other than that, I don't see the problem here. Please clarify your question; explain what your difficulty is.

    Comment

    • jandeerit
      New Member
      • Sep 2008
      • 12

      #3
      Originally posted by insertAlias
      Well, one big problem is that "ref" is a reserved word. It can't be used for variable names.

      Other than that, I don't see the problem here. Please clarify your question; explain what your difficulty is.

      oooppss.. my mistake...

      instead >>> int[] x = new int[6];

      I want to store the values of RefX & RefY inside x where the resulting array would be {10,12,20,22,30 ,33}

      By the way, I was able to solve my problem.. :)

      int j = 0;
      int[] RefX = new int[3] { 10, 20, 30 };
      int[] RefY = new int[3] { 11, 22, 33 };
      int[] x = new int[6];
      for (int i = 0; i < x.Length; i = i + 2)
      {
      x[i] = RefX[j];
      x[i + 1] = RefY[j];
      j = j + 1;
      }

      Thanks!

      Comment

      Working...