out - Two Same variable declared in C# -


i found code online i'm using in program, surprise found out there variable/function declared twice...

now, if i'm send value dll, of 2 send info to? 1 use out, while second not... see code:

[dllimport("msman.dll", callingconvention=callingconvention.stdcall, charset=charset.ansi, exactspelling=false)]         public static extern bool receive(int id, double[] bid, double[] ask);          public bool receive(int id, out double first, out double second)         {             bool flag;             double[] array1st = new double[1];             double[] array2nd = new double[1];             if (form1.receive(id, array1st, array2nd))             {                 first = array2nd[0];                 second = array1st[0];                 flag = true;             }             else             {                 second = 0;                 first = 0;                 flag = false;             }             return flag;         } 

edit: downvoters, if didn't see this. making bold make blind eyes work.. now, if i'm send value dll, of 2 send info to? 1 use out, while second not... and, why possible declare 2 variables..

my c# isn't great, looks standard case of method overloading.

note signature each method

a: public static extern bool receive(int id, double[] bid, double[] ask); b: public bool receive(int id, out double first, out double second) 

a takes following parameters: int, double[], double[] while b takes int, double, double. note difference in types. when call it, compiler says "oh, want call receive int , 2 double arrays. got it, here go!" , serves a

example of how call works:

int x = 1; double y = 1.0; double z = 2.0; receive(x, y, z); // <-- calls second method (b).  int x = 1; double[] y = new double[1]; double[]z = new double[1]; y[0] = 1.0; z[0] = 1.0; receive(x, y, z); // <-- calls first method (a) 

Comments