Gets or sets the format provider to use when formatting strings
Syntax
Visual Basic (Declaration) | |
---|
Public Shared WriteOnly Property FormatProvider As IFormatProvider |
Example
Log/Test/ConfigTest.cs
C# | Copy Code |
---|
DateTime now = DateTime.Now;
string cultured = String.Format("{0}", now);
string invariant = String.Format(CultureInfo.InvariantCulture, "{0}", now);
Log.Write("{0}", now);
Assert.IsTrue(_lastTrace.StartsWith(GetType().FullName + ": "));
string trimed = _lastTrace.Substring(GetType().FullName.Length + 2);
Assert.AreEqual(invariant, trimed);
Log.Config.FormatProvider = CultureInfo.CurrentCulture;
Log.Write("{0}", now);
Assert.IsTrue(_lastTrace.StartsWith(GetType().FullName + ": "));
trimed = _lastTrace.Substring(GetType().FullName.Length + 2);
Assert.AreEqual(cultured, trimed);
Log.Config.FormatProvider = CultureInfo.InvariantCulture;
Log.Write("{0}", now);
Assert.IsTrue(_lastTrace.StartsWith(GetType().FullName + ": "));
trimed = _lastTrace.Substring(GetType().FullName.Length + 2);
Assert.AreEqual(invariant, trimed); |
VB.NET | Copy Code |
---|
Dim now As DateTime = DateTime.Now
Dim cultured As String = [String].Format("{0}", now)
Dim invariant As String = [String].Format(CultureInfo.InvariantCulture, "{0}", now)
Log.Write("{0}", now)
Assert.IsTrue(_lastTrace.StartsWith([GetType]().FullName + ": "))
Dim trimed As String = _lastTrace.Substring([GetType]().FullName.Length + 2)
Assert.AreEqual(invariant, trimed)
Log.Config.FormatProvider = CultureInfo.CurrentCulture
Log.Write("{0}", now)
Assert.IsTrue(_lastTrace.StartsWith([GetType]().FullName + ": "))
trimed = _lastTrace.Substring([GetType]().FullName.Length + 2)
Assert.AreEqual(cultured, trimed)
Log.Config.FormatProvider = CultureInfo.InvariantCulture
Log.Write("{0}", now)
Assert.IsTrue(_lastTrace.StartsWith([GetType]().FullName + ": "))
trimed = _lastTrace.Substring([GetType]().FullName.Length + 2)
Assert.AreEqual(invariant, trimed) |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also