Advertisement
Paul17041993

C# copy though foreach test

Oct 26th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1.  
  2. namespace ConsoleApplication1
  3. {
  4.     class Program
  5.     {
  6.  
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.             testClass[] testArray = new testClass[8];
  11.  
  12.             testArray[4] = new testClass();
  13.             testArray[4].value = 2.0f;
  14.  
  15.             testClass temporary = null;
  16.  
  17.             foreach (testClass testme in testArray)
  18.             {
  19.                 if (testme != null)
  20.                 {
  21.                     temporary = testme;
  22.                 }
  23.             }
  24.  
  25.             Console.Write(temporary.value);
  26.  
  27.         }
  28.     }
  29.  
  30.     class testClass
  31.     {
  32.         public float value;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement