IT. Expert System.

C#

operator


Use the operator keyword to overload a built-in operator or to provide a user-defined conversion in a class or struct declaration.

Syntax:


Example:

using System;

class Widget
{
    public int _value;

    public static Widget operator +(Widget a, Widget b)
    {
	// Add two Widgets together.
	// ... Add the two int values and return a new Widget.
	Widget widget = new Widget();
	widget._value = a._value + b._value;
	return widget;
    }

    public static Widget operator ++(Widget w)
    {
	// Increment this widget.
	w._value++;
	return w;
    }
}

class Program
{
    static void Main()
    {
	// Increment widget twice.
	Widget w = new Widget();
	w++;
	Console.WriteLine(w._value);
	w++;
	Console.WriteLine(w._value);

	// Create another widget.
	Widget g = new Widget();
	g++;
	Console.WriteLine(g._value);

	// Add two widgets.
	Widget t = w + g;
	Console.WriteLine(t._value);
    }
}

/*Output

1
2
1
3*/


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 3577 / . Delta: 0.03357 с