Isn't that obvious that this instance is in the stack frame of a different method, never accessible from any other context?
When you create this instance, it will be made
unreachable to your program, so it will simply be removed but the Garbage Collector. The whole action is useless.
(To understand Garbage Collection, please see:
http://en.wikipedia.org/wiki/Garbage_collection_%28computer_science%29[
^].)
At the same time, in
exitToolStripMenuItem_Click
this instance has no value at all. In first occurrence of this undeclared name, you only need it to get the class, but you already know the class, this is
SyncJob
. When you serialize it, you can create the instance in the same exact way as in
newSyncJobToolStripMenuItem_Click
, but why? You don't need to serialize an object which is not populated with any data. In other words, the code does not show that you understand what you want to achieve.
For serialization, I don't recommend using
XmlSerializer
. Much more robust, universal, supportable and easy to use approach is
Data Contract:
http://msdn.microsoft.com/en-us/library/ms733127.aspx[
^].
And ultimately, sorry, there is no concrete help, as the whole idea makes no sense (or, I would say, absent). I'm sure that, before doing serialization, UI and other advanced things, you should solve some simpler problems to understand types and members, instances, and, essentially, OOP. Right now, you have no confidence at all. Not to worry: it will come soon, but you need to avoid rushing into more complex applications, learn the basics first.
—SA