Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does =+ mean and why does it compile?

Tags:

operators

c#

I've got the following typo:

subcomponentGroupCount = +subcomponentCount;

used in the following:

int subcomponentGroupCount = 0;

foreach (Subcomponent subcomponent in group.Subcomponents)
{
    int subcomponentCount = task.TaskDevice.TaskDeviceSubcomponents.Count(tds => tds.TemplateID == subcomponent.TemplateID);
    subcomponentGroupCount = +subcomponentCount;
}

I intended it to be +=, but I'm left wondering what "= +var" means..

like image 453
Sean Anderson Avatar asked Feb 12 '14 23:02

Sean Anderson


People also ask

What do u mean by compile?

verb (used with object), com·piled, com·pil·ing. to put together (documents, selections, or other materials) in one book or work. to make (a book, writing, or the like) of materials from various sources: to compile an anthology of plays; to compile a graph showing changes in profit. to gather together: to compile data.

Why do you compile?

Compiling allows the computer to run and understand the program without the need of the programming software used to create it. When a program is compiled it is often compiled for a specific platform (e.g., IBM platform) that works with IBM compatible computers, but not other platforms (e.g., Apple platform).

What does it mean to compile data?

Data compilation is the collation of raw data and their transformation into a format that can be easily manipulated or combined with other data in preparation for further analysis.

What does it mean to compile reports?

When you compile something such as a report, book, or programme, you produce it by collecting and putting together many pieces of information.


1 Answers

The + operator can be used as a binary or a unary operator. From MSDN:

Unary + operators are predefined for all numeric types. The result of a unary + operation on a numeric type is just the value of the operand.

You can overload this operator for custom types, but for the built-in numeric types, this is essentially a no-op.

like image 177
p.s.w.g Avatar answered Sep 18 '22 22:09

p.s.w.g