Binary flow is very convenient to use, in order to better understand the application of it, I created a simple object to start testing its increased features and reduce features.
[Serializable]classData----------storage object at start time { Public stringName ="Namex"; Public stringCeshia ="AA"; Public stringCeshib ="BB"; } [Serializable]classData----------Modify the storage class in your code and add a new field { Public stringName ="Namex"; Public stringCeshia ="AA"; Public stringCeshib ="BB"; Public stringCeshic ="cc"; Public intMD = +; Public Longml =2; }//after reading, the newly added values are given default initial values instead of the initial values specified in the code because they do not exist in the original storage file. stringCeshic =NULL; intMD =0; Longml =0;//After you reduce the data, the original value is not affected. Store extra values are automatically ignored[Serializable]classData----------Modify the storage class in your code, { Public stringName ="Namex"; Public stringCeshia ="AA"; Public stringCeshib ="BB"; //Public String ceshic = "CC"; //public int MD = 21; //Public long ml = 2; }//Note that the new added variable name can not be stored in the same name of the variable, if the same, the system will not because the variable type, but the judgment is a different variable value, and will throw an exception, reminding you that you cannot convert.[Serializable]classData----------Modify the storage class in your code, { Public stringName ="Namex"; Public stringCeshia ="AA"; Public stringCeshib ="BB"; //Public String ceshic = "CC"; //public int MD = 21; //Public long ml = 2; Public stringml =2;//The newly added variable name is the same as the previously stored data variable name}
So when you add or delete a field multiple times, try to keep the name of the variable different, so that the increment or decrement field will remain compatible with the previous stored file!
Binary Stream BinaryFormatter Store read data details test