Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
Hello codeproject,

I have a project and I don't know if I should make my enum serializable or if it won't affect the use of my project.
This is how it works:

C#
public enum ColorOfFood { values }

[Serializable]
public class Food
{
   private string name;
   private ColorOfFood color;
}

[Serializable]
public class FoodList { List<Food> }



My ultimate goal is to save both the values of the class Food using a binairyFormatter.
I should be able to save and retrieve them. (And ofcourse use them)

Thanks in regards,
Bert
Posted

1 solution

Enumerations are serializable by nature (they are constant integer values). You don't have to bother :)
Why not just making a simple trivial test to check it?
Kind regards.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 20-Jun-14 23:02pm    
5ed; perfect answer, especially the suggestion about the check. :-)
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900