<?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%2FOperator_Overload%2FCast_operator</id>
		<title>Csharp/CSharp Tutorial/Operator Overload/Cast operator - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FOperator_Overload%2FCast_operator"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Operator_Overload/Cast_operator&amp;action=history"/>
		<updated>2026-04-30T00:12:03Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Operator_Overload/Cast_operator&amp;diff=6394&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/Operator_Overload/Cast_operator&amp;diff=6394&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/Operator_Overload/Cast_operator&amp;diff=6395&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Operator_Overload/Cast_operator&amp;diff=6395&amp;oldid=prev"/>
				<updated>2010-05-26T12:18:54Z</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;==explicit/implicit operator for Complex==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
public struct Complex&lt;br /&gt;
{&lt;br /&gt;
    public Complex( double real, double imaginary ) {&lt;br /&gt;
        this.real = real;&lt;br /&gt;
        this.imaginary = imaginary;&lt;br /&gt;
    }&lt;br /&gt;
    // System.Object override&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format( &amp;quot;({0}, {1})&amp;quot;, real, imaginary );&lt;br /&gt;
    }&lt;br /&gt;
    public double Magnitude {&lt;br /&gt;
        get {&lt;br /&gt;
            return Math.Sqrt( Math.Pow(this.real, 2) + Math.Pow(this.imaginary, 2) );&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public static implicit operator Complex( double d ) {&lt;br /&gt;
        return new Complex( d, 0 );&lt;br /&gt;
    }&lt;br /&gt;
    public static explicit operator double( Complex c ) {&lt;br /&gt;
        return c.Magnitude;&lt;br /&gt;
    }&lt;br /&gt;
    private double real;&lt;br /&gt;
    private double imaginary;&lt;br /&gt;
}&lt;br /&gt;
public class EntryPoint&lt;br /&gt;
{&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        Complex cpx1 = new Complex( 1.0, 3.0 );&lt;br /&gt;
        Complex cpx2 = 2.0;         // Use implicit operator.&lt;br /&gt;
        double d = (double) cpx1;   // Use explicit operator.&lt;br /&gt;
        Console.WriteLine( &amp;quot;cpx1 = {0}&amp;quot;, cpx1 );&lt;br /&gt;
        Console.WriteLine( &amp;quot;cpx2 = {0}&amp;quot;, cpx2 );&lt;br /&gt;
        Console.WriteLine( &amp;quot;d = {0}&amp;quot;, d );&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;cpx1 = (1, 3)&lt;br /&gt;
cpx2 = (2, 0)&lt;br /&gt;
d = 3.16227766016838&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==implicit and explicit operator cast==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
    class MyType&lt;br /&gt;
    {&lt;br /&gt;
        int value;&lt;br /&gt;
        public MyType( int b )&lt;br /&gt;
        {&lt;br /&gt;
            value = b;&lt;br /&gt;
        }&lt;br /&gt;
        public static implicit operator int( MyType a )&lt;br /&gt;
        {&lt;br /&gt;
            return a.value;&lt;br /&gt;
        }&lt;br /&gt;
        public static explicit operator string( MyType a )&lt;br /&gt;
        {&lt;br /&gt;
            return &amp;quot;$&amp;quot; + a.value;&lt;br /&gt;
        }&lt;br /&gt;
        static void Main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
            MyType bal = new MyType( 777 );&lt;br /&gt;
            Console.WriteLine(&amp;quot;since int conversion is implicit we can write&amp;quot;);&lt;br /&gt;
            int i = bal;&lt;br /&gt;
            Console.WriteLine(&amp;quot;string conveersion must be explicitly requested&amp;quot;);&lt;br /&gt;
            string str = (string)bal;&lt;br /&gt;
            // this causes a compilation error&lt;br /&gt;
            // str = bal;&lt;br /&gt;
            System.Console.WriteLine( &amp;quot;i = {0} \nstr = {1}&amp;quot;, i, str );&lt;br /&gt;
        }&lt;br /&gt;
    }&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;since int conversion is implicit we can write&lt;br /&gt;
string conveersion must be explicitly requested&lt;br /&gt;
i = 777&lt;br /&gt;
str = $777&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>