Skip to content

3ab97e46 ee56 0924 bdb6 ef0c3018df64

Axel Kesseler edited this page May 5, 2019 · 18 revisions

TypeFormatterExtension.TryFormat(TValue) Method (TValue, String, IFormatProvider, String, Exception)

This method tries to convert provided value into string using provided format as well as provided format provider.

Namespace: Plexdata.LogWriter.Internals.Extensions
Assembly: Plexdata.LogWriter.Abstraction (in Plexdata.LogWriter.Abstraction.dll) Version: 1.0.2.3

Syntax

C#

public static bool TryFormat<TValue>(
	this TValue value,
	string format,
	IFormatProvider provider,
	out string result,
	out Exception error
)

Parameters

 

value
Type: TValue
The value to be converted.
format
Type: System.String
Any of the allowed format string of the type to be converted.
provider
Type: System.IFormatProvider
The format provider to be used for conversion.
result
Type: System.String
The string representation of provided value if conversion was successful, and null if not.
error
Type: System.Exception
An exception instance to get extended error information.

Type Parameters

 

TValue
The type to be converted.

Return Value

Type: Boolean
True if conversion was successful and false otherwise.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type . When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

The provided value is converted using provided format provider and does specific string formatting according to provided format.

This method always returns false either if type of TValue is not supported, or if parameter provider is null, or if any exception is thrown.

See Also

Reference

TypeFormatterExtension Class
TryFormat Overload
Plexdata.LogWriter.Internals.Extensions Namespace

Clone this wiki locally