I am writing a C# console application where I have a class Customer as following:
public class Customers
{
public string Name { get; set; }
public string UserID { get; set; }
public int Pin { get; set; }
public int AccountNo { get; set; }
public string AccountType { get; set; }
public int Balance { get; set; }
public string Status { get; set; }
}
I am storing the customer data in text file as below ("Customers.txt"):
[
{"Name":"Jack Willson","UserID":"Jack21","Pin":12345,"AccountNo":1,"AccountType":"Savings","Balance":2000,"Status":"Active"},
{"Name":"Mary Poppins","UserID":"mary8912","Pin":67890,"AccountNo":2,"AccountType":"Savings","Balance":4567,"Status":"Active"},
{"Name":"Harry Potter","UserID":"Harry45","Pin":12345,"AccountNo":4,"AccountType":"Savings","Balance":12000,"Status":"Active"}
]
I am reading this file as :
List<Customers> list = ReadFile<Customers>("Customers.txt");
I wish to update a specific customer field based on user input. If user leaves the field input blank then the field information remains unchanged.
The program will ask user to enter the AccountNo
for which he wishes to update an information.
Then program will display each property like UserID
, AccountType
, Status
. If the user doesnot enter any input for any of the property then information remains unchanged.
I was trying to save the input from user in new Customer()
object but couldn't proceed to compare it or save it in List<customers>
where i am storing the data from text file.
How can I achieve this?