Class Converter
Contains methods that peform string to object and vice versa conversions.
Inheritance
Namespace: FastReport.Utils
Assembly: FastReport.Base.dll
Syntax
public static class Converter
Methods
ConvertNull(Type)
Converts null value to 0, false, empty string, depending on type.
Declaration
public static object ConvertNull(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The data type. |
Returns
Type | Description |
---|---|
System.Object | The value of the type data type. |
DecreasePrecision(Single, Int32)
Decreases the precision of floating-point value.
Declaration
public static float DecreasePrecision(float value, int precision)
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | The initial value. |
System.Int32 | precision | The number of decimal digits in the fraction. |
Returns
Type | Description |
---|---|
System.Single | The value with lesser precision. |
FromHtmlEntities(String, ref Int32, out String)
Convert &	" etc to symbol and return result as string
Declaration
public static bool FromHtmlEntities(string text, ref int position, out string result)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | String for processing |
System.Int32 | position | Position for processing |
System.String | result | Result of processing |
Returns
Type | Description |
---|---|
System.Boolean | True if successful |
FromHtmlEntities(String, ref Int32, StringBuilder)
Convert &	" etc to symbol and return result as string
Declaration
public static bool FromHtmlEntities(string text, ref int position, StringBuilder result)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | String for processing |
System.Int32 | position | Position for processing |
System.Text.StringBuilder | result | Append result of processing to FastString |
Returns
Type | Description |
---|---|
System.Boolean | True if successful |
FromString(String, Type)
Converts a string to an object using the specified converter.
Declaration
public static object FromString(string value, Type converterType)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string to convert. |
System.Type | converterType | The type of converter. |
Returns
Type | Description |
---|---|
System.Object | The object that contains the converted value. |
FromString(Type, String)
Converts a string value to the specified data type.
Declaration
public static object FromString(Type type, string value)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The data type to convert to. |
System.String | value | The string to convert from. |
Returns
Type | Description |
---|---|
System.Object | The object of type specified in the type parameter that contains a converted value. |
FromXml(String)
Convert the xml-compatible string to the regular one.
Declaration
public static string FromXml(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to convert. |
Returns
Type | Description |
---|---|
System.String | The result string. |
Remarks
This is counterpart to the ToXml(String) method.
IListToString(IList)
Converts a collection of strings to a string.
Declaration
public static string IListToString(IList list)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IList | list | The collection to convert. |
Returns
Type | Description |
---|---|
System.String | The string that contains all lines from the collection. |
StringToByteArray(String)
Converts string value to byte[].
Declaration
public static byte[] StringToByteArray(string Str)
Parameters
Type | Name | Description |
---|---|---|
System.String | Str | The string to convert |
Returns
Type | Description |
---|---|
System.Byte[] | The value of the byte[] data type. |
StringToFloat(String)
Converts a string value to the float.
Declaration
public static float StringToFloat(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string value to convert. |
Returns
Type | Description |
---|---|
System.Single | The float value. |
Remarks
Both "." or "," decimal separators are allowed.
StringToFloat(String, Boolean)
Converts a string value to the float.
Declaration
public static float StringToFloat(string value, bool removeNonDigit)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string value to convert. |
System.Boolean | removeNonDigit | Indicates whether to ignore non-digit symbols. |
Returns
Type | Description |
---|---|
System.Single | The float value. |
StringToFloat(String, String)
Converts a string value to the float.
Declaration
public static float StringToFloat(string value, string separator)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string value to convert. |
System.String | separator | Decimal separator. |
Returns
Type | Description |
---|---|
System.Single | The float value. |
StringToFloat(String, String, Boolean)
Converts a string value to the float.
Declaration
public static float StringToFloat(string value, string separator, bool removeNonDigit)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string value to convert. |
System.String | separator | Decimal separator. |
System.Boolean | removeNonDigit | Indicates whether to ignore non-digit symbols. |
Returns
Type | Description |
---|---|
System.Single | The float value. |
StringToIList(String, IList)
Converts the string containing several text lines to a collection of strings.
Declaration
public static void StringToIList(string text, IList list)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The string to convert. |
System.Collections.IList | list | The collection instance. |
StringToNameValueCollection(String)
Converts a string to NameValueCollection.
Declaration
public static NameValueCollection StringToNameValueCollection(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The string to convert. |
Returns
Type | Description |
---|---|
NameValueCollection | The NameValueCollection that contains the name/value pairs. |
ToString(Object)
Converts an object to a string.
Declaration
public static string ToString(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to convert. |
Returns
Type | Description |
---|---|
System.String | The string that contains the converted value. |
ToString(Object, Type)
Converts a value to a string using the specified converter.
Declaration
public static string ToString(object value, Type converterType)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to convert. |
System.Type | converterType | The type of converter. |
Returns
Type | Description |
---|---|
System.String | The string that contains the converted value. |
ToXml(Object)
Converts a value to xml-compatible string.
Declaration
public static string ToXml(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | The result string. |
ToXml(String)
Converts a string containing special symbols to the xml-compatible string.
Declaration
public static string ToXml(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to convert. |
Returns
Type | Description |
---|---|
System.String | The result string. |
Remarks
This method replaces some special symbols like <, > into xml-compatible form: <, >. To convert such string back to original form, use the FromXml(String) method.
ToXml(String, Boolean)
Converts a string containing special symbols to the xml-compatible string.
Declaration
public static string ToXml(string s, bool convertCrlf)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to convert. |
System.Boolean | convertCrlf | Determines whether it is necessary to convert cr-lf symbols to xml form. |
Returns
Type | Description |
---|---|
System.String | The result string. |