Coding in C# for complex number -
how normalize complex numbers in c#?when have saved text file of complex number in notepad.then want use these complex numbers in c# code.and can read text file of complex number in c#?
current code used:
  using (textreader reader = file.opentext("a.txt"))   {        var linecount1 = file.readlines("a.txt").count();        x1 = new double[linecount1, 512];        (int = 0; < linecount1; i++)        {          (int j = 0; j < 512; j++)               {                string line = reader.readline();                string[] bits = line.split(' ');                x1[i, j] = double.parse(bits[j]);               }        }     }   its not working.!!! error in last line.
perhaps should have this:
    static void main(string[] args)     {         var lines = file.readalllines("a.txt");         var complexes = new complex[lines.length];         (int = 0; < complexes.length; i++)         {             complexes[i] = parse(lines[i]);         }     }      private static complex parse(string s)     {         var split = s.split(new char[' '], stringsplitoptions.removeemptyentries); // guess string "12 54". if have "12 + 54i" you'l exception here         return new complex(double.parse(split[0]), double.parse(split[1]));     }      
Comments
Post a Comment