When overridden in a derived class, serializes properties and internal state specific to a derived code group and adds the serialization to the specified System.Security.SecurityElement.
CodeGroup.ToXml cannot be overridden. If you need to serialize members specific to a particular implementation of System.Security.Policy.CodeGroup, you must override CodeGroup.CreateXml(System.Security.SecurityElement, PolicyLevel) and serialize your members there. When the code group is serialized, CodeGroup.ToXml calls CodeGroup.CreateXml(System.Security.SecurityElement, PolicyLevel) and adds your serialization to the System.Security.SecurityElement created by CodeGroup.ToXml.
The XML created using this method is deserialized by the CodeGroup.ParseXml(System.Security.SecurityElement, PolicyLevel) method.