Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.IO;
- using System;
- using System.Linq;
- using System.Collections;
- using System.Collections.Generic;
- public struct Player
- {
- public string Name;
- public string Nickname;
- }
- public class Application
- {
- static void Main()
- {
- int i = 0;
- Console.WriteLine("Enter number of players:");
- int num_players = Convert.ToInt32(Console.ReadLine());
- Player[] players = new Player[num_players];
- for(i = 0; i < num_players; i++)
- {
- Console.WriteLine("Player Name:");
- players[i].Name = Console.ReadLine();
- Console.WriteLine("Player Nickname:");
- players[i].Nickname = Console.ReadLine();
- }
- foreach(Player x in players)
- {
- Console.WriteLine("Player Name: " + x.Name);
- Console.WriteLine("Player Nickname: " + x.Nickname);
- }
- Console.WriteLine("Quantos Players?");
- num_players = Convert.ToInt32(Console.ReadLine());
- Array.Resize(ref players, num_players);
- for(int k = 0; k == num_players; k--)
- {
- players[k] = players[k + 1];
- }
- for(; i < num_players; i++)
- {
- Console.WriteLine("Player Name:");
- players[i].Name = Console.ReadLine();
- Console.WriteLine("Player Nickname:");
- players[i].Nickname = Console.ReadLine();
- }
- foreach(Player x in players)
- {
- Console.WriteLine("Player Name: " + x.Name);
- Console.WriteLine("Player Nickname: " + x.Nickname);
- }
- string file_directory = @"Cache.txt";
- using (StreamWriter sw = File.CreateText(file_directory))
- {
- for(int k = 0; k < num_players; k++)
- {
- sw.WriteLine(players[k].Name);
- sw.WriteLine(players[k].Nickname);
- }
- }
- using (StreamReader sr = File.OpenText(file_directory))
- {
- string s = "";
- do{
- s = sr.ReadLine();
- if(s == null)
- {
- num_players = num_players + 1;
- Array.Resize(ref players, num_players);
- players[num_players].Name = s;
- }
- s = sr.ReadLine();
- if(s == null)
- {
- players[num_players].Nickname = s;
- }
- } while (s != null);
- }
- foreach(Player x in players)
- {
- Console.WriteLine(x.Name);
- Console.WriteLine(x.Nickname);
- }
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement