Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // View the video tutorial here: https://www.youtube.com/watch?v=glyfSt5mh1Y
- // © Dan Parker 2014 - wangoland@gmail.com
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace Writing_to_a_Text_File
- {
- class Program
- {
- static void Main(string[] args)
- {
- // Take 5 string inputs -> Store them in an array
- // -> Write the array to a text file
- // Define our one and only variable
- string[] names = new string[5]; // Array to hold the names
- Console.WriteLine("Enter 5 names to write to a text file: ");
- for (int i = 0; i < 5; i++)
- {
- names[i] = Console.ReadLine();
- }
- // Write this array to a text file
- StreamWriter SW = new StreamWriter(@"names.txt");
- for(int i = 0; i < 5; i++)
- {
- SW.WriteLine(names[i]);
- }
- SW.Close();
- }
- }
- }
Add Comment
Please, Sign In to add comment