Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In c# are Decimal and decimal different?

Tags:

c#

types

In c# if I use decimal (lower case 'd'), the IDE shows it in dark blue (like int). If I use Decimal (upper case 'd'), the IDE shows it in teal (like a class name). In both cases the tooltip is struct System.Decimal.

Is there any difference? Is one "preferred"?

like image 902
Jon B Avatar asked Dec 22 '09 15:12

Jon B


People also ask

What is '~' in C language?

In mathematics, the tilde often represents approximation, especially when used in duplicate, and is sometimes called the "equivalency sign." In regular expressions, the tilde is used as an operator in pattern matching, and in C programming, it is used as a bitwise operator representing a unary negation (i.e., "bitwise ...

What does the || mean in C?

The logical OR operator ( || ) returns the boolean value true if either or both operands is true and returns false otherwise.

What is operators in C?

C operators are one of the features in C which has symbols that can be used to perform mathematical, relational, bitwise, conditional, or logical manipulations. The C programming language has a lot of built-in operators to perform various tasks as per the need of the program.

What does -= mean in C++?

This operator first subtracts the value on the right from the current value of the variable on left and then assigns the result to the variable on the left. Example: (a -= b) can be written as (a = a - b) If initially value stored in a is 8. Then (a -= 6) = 2.


1 Answers

Nope; identical. decimal is defined as an alias to System.Decimal, and is generally preferred, except in public method names, where you should use the proper name (ReadDecimal, etc) - because your callers might not be C#. This is more noticeable in int vs ReadInt32, etc.

There certainly isn't the Java-style boxing difference.

(of course, if you do something like declare a more-namespace-local Decimal that does something completely different, then there are differences, but that would be silly).

like image 147
Marc Gravell Avatar answered Oct 07 '22 20:10

Marc Gravell