public static void Menu(Hero hero) { Program.code = 0; Program.menuItem = 1; Program.cursorPosition[0] = '>'; do { Console.Clear(); Console.Write("\n{0} Новая игра\n{1} Выход", Program.cursorPosition[0], Program.cursorPosition[1]); Program.code = Program.Cursor(2); } while (Program.code == 0); if (Program.code == 1) { Tutorial.Start(hero); } else if (Program.code == 2) { Console.Clear(); Environment.Exit(0); } }
static void Main(string[] args) { //toturial obj = new toturial(); //obj.ID = 1; //obj.name = "MrLotfi"; //IFormatter formatter = new BinaryFormatter(); //Stream stream = new FileStream("E:\\example.txt", FileMode.Create, FileAccess.ReadWrite); //formatter.Serialize(stream,obj); //stream.Close(); Tutorial obj = new Tutorial(); obj.ID = 1; obj.Name = ".Net"; IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(@"E:\ExampleNew.txt", FileMode.Create, FileAccess.Write); formatter.Serialize(stream, obj); stream.Close(); SqlConnection conn = new SqlConnection("Your SQL Connection String"); conn.Open(); StringBuilder str = new StringBuilder(); str.AppendLine("DECLARE @tImage AS VARBINARY(MAX)"); str.AppendLine(@"SELECT @tImage = CAST(bulkcolumn AS VARBINARY(MAX)) FROM OPENROWSET( BULK 'E:\ExampleNew.txt', SINGLE_BLOB ) AS x"); str.AppendLine(@"INSERT INTO TblPhotos (ID, Name, Images) SELECT NEWID(), 'E:\ExampleNew.txt',@tImage"); SqlCommand cmd = new SqlCommand(str.ToString(), conn); cmd.ExecuteNonQuery(); Console.WriteLine("Image Saved Successfully..."); stream = new FileStream(@"E:\ExampleNew.txt", FileMode.Open, FileAccess.Read); Tutorial objnew = (Tutorial)formatter.Deserialize(stream); Console.WriteLine(objnew.ID); Console.WriteLine(objnew.Name); Console.ReadKey(); }
public static void Start(Hero hero) { Program.code = 0; Program.menuItem = 1; Program.cursorPosition[0] = '>'; do { Console.Clear(); hero.PrintInfo(); Console.WriteLine(" Пробираясь через болото, вы наткнулись на тварь, она выглядит враждебно"); Console.WriteLine(); Console.Write("\n{0} Атаковать\n{1} Принять судьбу", Program.cursorPosition[0], Program.cursorPosition[1]); Program.code = Program.Cursor(2); } while (Program.code == 0); if (Program.code == 1) { Tutorial.Battle(hero, EnemyType.Tvar); } else if (Program.code == 2) { Console.Clear(); hero.Death(hero); } Tutorial.Tma(hero); }