Can I serialize a C# Type object?

前端 未结 6 1543
南方客
南方客 2020-12-04 17:18

I\'m trying to serialize a Type object in the following way:

Type myType = typeof (StringBuilder);
var serializer = new XmlSerializer(typeof(Type));
TextWrit         


        
6条回答
  •  离开以前
    2020-12-04 17:54

    According to the MSDN documentation of System.Type [1] you should be able to serialize the System.Type object. However, as the error is explicitly referring to System.Text.StringBuilder, that is likely the class that is causing the serialization error.

    [1] Type Class (System) - http://msdn.microsoft.com/en-us/library/system.type.aspx

提交回复
热议问题