// Create a SerializationInfo object SerializationInfo info = new SerializationInfo(typeof(Person), new FormatterConverter()); // Add a string value to SerializationInfo object info.AddValue("Name", "John"); // Retrieve the string value using GetString() string name = info.GetString("Name");
// Create a SerializationInfo object SerializationInfo info = new SerializationInfo(typeof(Person), new FormatterConverter()); // Add an array of string values to SerializationInfo object string[] addresses = new string[] { "123 Main St", "456 Center Ave" }; info.AddValue("Addresses", addresses, typeof(string[])); // Retrieve the array of string values using GetString() string[] retrievedAddresses = (string[])(info.GetValue("Addresses", typeof(string[])));In this example, we add an array of string values to the SerializationInfo object and retrieve it using the GetValue() method. Then we cast the retrieved value to an array of strings and store it in a variable. The System.Runtime.Serialization package is a part of the .NET Framework library.