Casting data to type of variables stored in object[]
问题 I am trying to emulate the way fortran reads data from text files in C#. In fortran you have something like READ(60,2005,ERR=9880,END=8000) A,B,C,D 2005 FORMAT(I8,A20,2F10.3) and A, B, C, D are automatically set to the correct type based on the format statement. I have tried things along the lines of: private static void Example(string[] Data, ref object[] Variables) { for (int i = 0; i < Data.Length; i++) Variables[i] = (typeof(Variables[i]))Data; } but can't even get code that will compile.