public static void SaveFunc(string fileName, OneFun F, double a, double b, double h) { FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write); BinaryWriter bw = new BinaryWriter(fs); double x = a; while (x <= b) { bw.Write(F(x)); x += h; } bw.Close(); fs.Close(); }
static void Main(string[] args) { double userX = 0; double userY = 0; OneFun[] Func_list = new OneFun[] { F1, F2, F3 }; Table(new Fun(MyFunc), 1, 3, 5); Console.WriteLine(); Table(SinFunc, -1, 3, 2); Console.WriteLine(); Console.WriteLine("Put in coordinates for your function"); userX = int.Parse(Console.ReadLine()); Console.WriteLine("Put in coordinates for your function"); userY = int.Parse(Console.ReadLine()); Console.WriteLine("Choose which function you would like to use: 1, 2 or 3"); var userFun = int.Parse(Console.ReadLine()); if (userFun == 1) { SaveFunc("data.bin", Func_list[0], userX, userY, 1); } else if (userFun == 2) { SaveFunc("data.bin", Func_list[1], userX, userY, 1); } else if (userFun == 3) { SaveFunc("data.bin", Func_list[2], userX, userY, 1); } else { Console.WriteLine("Uncorrect"); } Console.WriteLine(Load("data.bin")); Console.ReadKey(); }