Avatar of jeffiepoo
jeffiepoo
Flag for United States of America asked on

Simple C# program question

Experts,

I'm new to C#, but I'm really good with java so I thought I would familiarize myself with C# by doing a simple project. There is one MAJOR thing I need information about, and I'm going to ask you guys.

For programs in the past and in school, we would write our own data structures. These structures would be filled either by parsing input or files or whatever.

I want this program to SAVE the data in it's data structure, so when it loads up the data is already in the program.

I need a SIMPLE AS PIE way to do this. I do not want to write a program that outputs everything to a specific format that I've developed myself and then parses the information later. In other words, I want a library of data structures that has this functionality (or any other way to do this is fine).

I don't know much about databases, but if there is a database I could use to save info then output to a file, then use it to read the file into the program again or something? I don't have a web server or anything to host anything btw.

Any recommendations would be awesome! Thanks guys!

-Jeff
C#Databases

Avatar of undefined
Last Comment
mrjoltcola

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Dhugal_L

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
jdavistx

Well, I suppose this is heavily stipulated by the type of data and what you want to do with the data.

Arguably, the "simplest" way would be to use application settings
http://msdn.microsoft.com/en-us/library/k4s6c3a0.aspx

You can store user/application specific settings which you can load in to your application.  The settings persist between execution, and provide a relatively simple way to save/edit some types of data.

Alternatively, besides using a database, .NET provides all kinds of great facilities for working with XML files.  You can generate and manipulate XML files with relative ease.  Using Linq-to-XML makes the process all the simpler.
jeffiepoo

ASKER
Looks like a WONDERFUL suggestion thanks.

One question:

Have you used this?

If so, in the example, could I make my "public class ObjectToSerialize" class a fully functional class that holds all my data (private data structures) with getter/setter methods, a constructor, ect. And just serialize it like the rest of the example shows.

Is it really this simple? If so that is awesome. Do you know of any equivalent things in Java?

-Jeff
jeffiepoo

ASKER
Also,

What is the second part of the code below, it looks like a getter and setter for the list? What else can this notation be used on? Is it standard?

   private List<Car> cars;

   public List<Car> Cars
   {
      get { return this.cars; }
      set { this.cars = value; }
   }

After this I'm done asking new questions. Thanks guys,

-Jeff
Your help has saved me hundreds of hours of internet surfing.
fblack61
SOLUTION
mrjoltcola

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
mrjoltcola

That is standard property notation. So you can use

obj.Cars = ...

Instead of obj.setCars(...)

Another lesson that C# team learned from Java/C++