✅ Need help with storing data and that it can be using with a C# .NET 7 console application
Hello, Can someone tell me or send me a video tutorial on how to store user input data into a text file, and then being able to see all the data stored in it?
I am using MS C# .NET 7, and I am pretty new to programming.
It would be preferable to get a video tutorial that is about 10 or so minutes long.
9 Replies
What kind of data?
Plain text? Or something more structured?
well, I am trying to make a console application that is like a library that stores all of your read books.
It asks the user 2 questions
1. Would you like to add a new entry into the library?
2. Would you like to see the list of the books that you have read?
If 1 is selected, then the application asks 3 more questions.
1. Title of the book
2. Author of the book
3. Year of the book
After answering all questions, it says "Successfully added new entry into the library."
If 2 is selected, then it displays all the books with all information in an organized list (alphabetically is optional) and preferably for it to have a list like this:
1. book 1
2. book 2
3. book 3
It seems like a JSON file should be sufficient, then
yeah, maybe
though I have not learned this so far, would it be possible to learn it by myself?
await File.WriteAllTextAsync()
can write a string to a given file
await File.ReadAllTextAsync()
can read a given file to a string
JsonSerializer.Serialize()
can turn an object into a JSON-formatted string
JsonSerializer.Deserialize<T>()
can turn a JSON-formatted string into object of type T
Combining those should sufficethank you, I shall make an attempt to code the program using these functions
how do I add a json file on VS 2022?
You don't need to, the first time you write to it it will be created automatically
oh nice
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.