Returns the property value as a string formatted according to the current locale.
[Visual Basic]Overrides Public Function ToString() As
String [C#]public override
string ToString();
Remarks
Converts a boolean property into "Y" or "N". Converts a date property into a short date string. For all other types converts a property using Object.ToString().
Example
Retrieves a built-in document property by name.
[C#]
Document doc = new Document(MyDir + "Properties.doc");
DocumentProperty prop = doc.BuiltInDocumentProperties["Keywords"];
Console.WriteLine(prop.ToString());
[Visual Basic]
Dim doc As Document = New Document(MyDir & "Properties.doc")
Dim prop As DocumentProperty = doc.BuiltInDocumentProperties("Keywords")
Console.WriteLine(prop.ToString())Retrieves the types and values of the custom document properties.
[C#]
Document doc = new Document(MyDir + "Properties.doc");
foreach (DocumentProperty prop in doc.CustomDocumentProperties)
{
Console.WriteLine(prop.Name);
switch (prop.Type)
{
case PropertyType.String:
Console.WriteLine("It's a string value.");
Console.WriteLine(prop.ToString());
break;
case PropertyType.Boolean:
Console.WriteLine("It's a boolean value.");
Console.WriteLine(prop.ToBool());
break;
case PropertyType.Number:
Console.WriteLine("It's an integer value.");
Console.WriteLine(prop.ToInt());
break;
case PropertyType.DateTime:
Console.WriteLine("It's a date time value.");
Console.WriteLine(prop.ToDateTime());
break;
case PropertyType.Double:
Console.WriteLine("It's a double value.");
Console.WriteLine(prop.ToDouble());
break;
case PropertyType.Other:
Console.WriteLine("Other value.");
break;
default:
throw new Exception("Unknown property type.");
}
}[Visual Basic]
Dim doc As Document = New Document(MyDir & "Properties.doc")
For Each prop As DocumentProperty In doc.CustomDocumentProperties
Console.WriteLine(prop.Name)
Select Case prop.Type
Case PropertyType.String
Console.WriteLine("It's a string value.")
Console.WriteLine(prop.ToString())
Case PropertyType.Boolean
Console.WriteLine("It's a boolean value.")
Console.WriteLine(prop.ToBool())
Case PropertyType.Number
Console.WriteLine("It's an integer value.")
Console.WriteLine(prop.ToInt())
Case PropertyType.DateTime
Console.WriteLine("It's a date time value.")
Console.WriteLine(prop.ToDateTime())
Case PropertyType.Double
Console.WriteLine("It's a double value.")
Console.WriteLine(prop.ToDouble())
Case PropertyType.Other
Console.WriteLine("Other value.")
Case Else
Throw New Exception("Unknown property type.")
End Select
Next propSee Also
DocumentProperty Class | Aspose.Words.Properties Namespace