Home > Net >  C # output two-dimensional array has been display System. Double [and] is how to return a responsibi
C # output two-dimensional array has been display System. Double [and] is how to return a responsibi

Time:09-25



Is to put the two dimensional array results output to a TXT file, but after running TXT file is shown in System. Double [and] is why?

CodePudding user response:

The
refer to the original poster WalYMJ_ response:
...
Is to put the two dimensional array results output to a TXT file, but after running TXT file is shown in System. Double [and] is why?


Because of two-dimensional array default ToString implementation is the type of print it,
You want to put the two dimension of output formats, such as
 static void Print (double [and] matrix, System. IO. TextWriter writer) 
{
For (int y=0; Y & lt; Matrix. GetLength (0); Y++)
{
For (int x=0; x {
Writer. Write (" {0, 6}, "matrix [y, x]).
}
Writer. WriteLine ();
}
}


Then you can:
Print (BT, wr);
Print (Nbb, wr);

CodePudding user response:

Output is a string representation of a two-dimensional array form, not the real value, see # 1,

CodePudding user response:

You will direct the ToString?
  •  Tags:  
  • C#
  • Related