<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FClass%2FICustomFormatter</id>
		<title>Csharp/CSharp Tutorial/Class/ICustomFormatter - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FClass%2FICustomFormatter"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/ICustomFormatter&amp;action=history"/>
		<updated>2026-04-29T23:12:57Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/ICustomFormatter&amp;diff=5657&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/ICustomFormatter&amp;diff=5657&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:53Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/ICustomFormatter&amp;diff=5658&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Class/ICustomFormatter&amp;diff=5658&amp;oldid=prev"/>
				<updated>2010-05-26T12:16:08Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==ICustomFormatter  IFormatProvider==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;/*&lt;br /&gt;
Quote from&lt;br /&gt;
Accelerated C# 2005&lt;br /&gt;
# By Trey Nash&lt;br /&gt;
# ISBN: 1-59059-717-6&lt;br /&gt;
# 432 pp.&lt;br /&gt;
# Published: Aug 2006&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Globalization;&lt;br /&gt;
public class ComplexDbgFormatter : ICustomFormatter, IFormatProvider&lt;br /&gt;
{&lt;br /&gt;
    public object GetFormat( Type formatType ) {&lt;br /&gt;
        if( formatType == typeof(ICustomFormatter) ) {&lt;br /&gt;
            return this;&lt;br /&gt;
        } else {&lt;br /&gt;
            return CultureInfo.CurrentCulture.&lt;br /&gt;
                GetFormat( formatType );&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public string Format( string format, object arg, IFormatProvider formatProvider ) {&lt;br /&gt;
        if( arg.GetType() == typeof(Complex) &amp;amp;&amp;amp; format == &amp;quot;DBG&amp;quot; ) {&lt;br /&gt;
            Complex cpx = (Complex) arg;&lt;br /&gt;
            StringBuilder sb = new StringBuilder();&lt;br /&gt;
            sb.Append( arg.GetType().ToString() + &amp;quot; &amp;quot; );&lt;br /&gt;
            sb.AppendFormat( &amp;quot;Real:{0} &amp;quot;, cpx.Real );&lt;br /&gt;
            sb.AppendFormat( &amp;quot;Img: {0} &amp;quot;, cpx.Img );&lt;br /&gt;
            return sb.ToString();&lt;br /&gt;
        } else {&lt;br /&gt;
            IFormattable formatable = arg as IFormattable;&lt;br /&gt;
            if( formatable != null ) {&lt;br /&gt;
                return formatable.ToString( format, formatProvider );&lt;br /&gt;
            } else {&lt;br /&gt;
                return arg.ToString();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public struct Complex : IFormattable&lt;br /&gt;
{&lt;br /&gt;
    public Complex( double Real, double Img ) {&lt;br /&gt;
        this.Real = Real;&lt;br /&gt;
        this.Img = Img;&lt;br /&gt;
    }&lt;br /&gt;
    public string ToString( string format, IFormatProvider formatProvider ) {&lt;br /&gt;
        StringBuilder sb = new StringBuilder();&lt;br /&gt;
        sb.Append( &amp;quot;( &amp;quot; + Real.ToString(format, formatProvider) );&lt;br /&gt;
        sb.Append( &amp;quot; : &amp;quot; + Img.ToString(format, formatProvider) );&lt;br /&gt;
        sb.Append( &amp;quot; )&amp;quot; );&lt;br /&gt;
        return sb.ToString();&lt;br /&gt;
    }&lt;br /&gt;
    public double Real;&lt;br /&gt;
    public double Img;&lt;br /&gt;
}&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        CultureInfo local = CultureInfo.CurrentCulture;&lt;br /&gt;
        CultureInfo germany = new CultureInfo( &amp;quot;de-DE&amp;quot; );&lt;br /&gt;
        Complex cpx = new Complex( 12.3456, 1234.56 );&lt;br /&gt;
        string strCpx = cpx.ToString( &amp;quot;F&amp;quot;, local );&lt;br /&gt;
        Console.WriteLine( strCpx );&lt;br /&gt;
        strCpx = cpx.ToString( &amp;quot;F&amp;quot;, germany );&lt;br /&gt;
        Console.WriteLine( strCpx );&lt;br /&gt;
        ComplexDbgFormatter dbgFormatter = new ComplexDbgFormatter();&lt;br /&gt;
        strCpx = String.Format( dbgFormatter,&amp;quot;{0:DBG}&amp;quot;,  cpx );&lt;br /&gt;
        Console.WriteLine( &amp;quot;\nDebugging output:\n{0}&amp;quot;, strCpx );&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;( 12.35 : 1234.56 )&lt;br /&gt;
( 12,35 : 1234,56 )&lt;br /&gt;
Debugging output:&lt;br /&gt;
Complex Real:12.3456 Img: 1234.56&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>