nedcomp hosting homepage

Producten en Diensten
Dedicated servers
Datacenter informatie
Partners, resellers
Helpdesk informatie
Technische docs, tools
Support homepage
ASP componenten
Praktische ASP, ASP.NET
Visual route server
Whois (domein gegevens)
Software documentatie
Whitepapers
Zoeken
Nedcomp / algemeen

Zoeken
 

Copyright © Nedcomp Hosting
Telefoon nr :   +31 184 670111
Fax nummer :   +31 184 631384
E-mailadres :   info@nedcomp.nl
 

C# Programmer's Reference  

= Operator

The assignment operator (=) stores the value of its right-hand operand in the storage location, property, or indexer denoted by its left-hand operand and returns the value as its result. The operands must be of the same type (or the right-hand operand must be implicitly convertible to the type of the left-hand operand).

lhs = expr

Where:

lhs
A storage location, property, or indexer.
expr
An expression.

Remarks

The assignment operator cannot be overloaded.

Example

// cs_operator_assignment.cs
using System;
class Test 
{
   public static void Main() 
   {
      double x;
      int i;
      i = 5; // int to int assignment
      x = i; // implicit conversion from int to double
      i = (int)x; // needs cast
      Console.WriteLine("i is {0}, x is {1}", i, x);
      object obj = i;
      Console.WriteLine("boxed value = {0}, type is {1}",
         obj, obj.GetType());
      i = (int)obj;
      Console.WriteLine("unboxed: {0}", i);
   }
}

Output

i is 5, x is 5
boxed value = 5, type is System.Int32
unboxed: 5

See Also

C# Operators | 7.13 Assignment operators