Hi,
I have a code that append a user input name to the end of list.
I like to know how I can check to see if user input matches with the name in file
if so print "name exists" if not print "name added to list"
Thank you for your time.
PS - How do I provide my code with proper spacing?
I have a code that append a user input name to the end of list.
I like to know how I can check to see if user input matches with the name in file
if so print "name exists" if not print "name added to list"
Thank you for your time.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Diagnostics; namespace ChatBot { class Program { static void Main(string[] args) { string filePath = @"C:\C#\Projects\names.txt"; List<string> lines = File.ReadAllLines(filePath).ToList(); Console.Write("Please enter your full name? "); string FullName = Console.ReadLine(); // append and write FullName to file lines.Add(FullName); File.WriteAllLines(filePath, lines); //displays result Process.Start(filePath); } } }
PS - How do I provide my code with proper spacing?