Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

40 changes: 20 additions & 20 deletions docs/csharp/language-reference/keywords/value-types-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ ms.assetid: 67d8f631-b6e3-4d83-9910-5ec497f8c5f3
---
# Value types table (C# Reference)

The following table shows the C# value types.
|Value type|Category|Type suffix|
|----------------|--------------|-----------------|
|[bool](bool.md)|Boolean||
|[byte](byte.md)|Unsigned, numeric, [integral](integral-types-table.md)||
|[char](char.md)|Unsigned, numeric, [integral](integral-types-table.md)||
|[decimal](decimal.md)|Numeric, [floating-point](floating-point-types-table.md)|M or m|
|[double](double.md)|Numeric, [floating-point](floating-point-types-table.md)|D or d|
|[enum](enum.md)|Enumeration||
|[float](float.md)|Numeric, [floating-point](floating-point-types-table.md)|F or f|
|[int](int.md)|Signed, numeric, [integral](integral-types-table.md)||
|[long](long.md)|Signed, numeric, [integral](integral-types-table.md)|L or l|
|[sbyte](sbyte.md)|Signed, numeric, [integral](integral-types-table.md)||
|[short](short.md)|Signed, numeric, [integral](integral-types-table.md)||
|[struct](struct.md)|User-defined structure||
|[uint](uint.md)|Unsigned, numeric, [integral](integral-types-table.md)|U or u|
|[ulong](ulong.md)|Unsigned, numeric, [integral](integral-types-table.md)|UL, Ul, uL, ul, LU, Lu, lU, or lu|
|[ushort](ushort.md)|Unsigned, numeric, [integral](integral-types-table.md)||
The following table shows the C# value types:

|Value type|Category|Type suffix|
|----------------|--------------|-----------------|
|[bool](bool.md)|Boolean||
|[byte](byte.md)|Unsigned, numeric, [integral](integral-types-table.md)||
|[char](char.md)|Unsigned, numeric, [integral](integral-types-table.md)||
|[decimal](decimal.md)|Numeric, [floating-point](floating-point-types-table.md)|M or m|
|[double](double.md)|Numeric, [floating-point](floating-point-types-table.md)|D or d|
|[enum](enum.md)|Enumeration||
|[float](float.md)|Numeric, [floating-point](floating-point-types-table.md)|F or f|
|[int](int.md)|Signed, numeric, [integral](integral-types-table.md)||
|[long](long.md)|Signed, numeric, [integral](integral-types-table.md)|L or l|
|[sbyte](sbyte.md)|Signed, numeric, [integral](integral-types-table.md)||
|[short](short.md)|Signed, numeric, [integral](integral-types-table.md)||
|[struct](struct.md)|User-defined structure||
|[uint](uint.md)|Unsigned, numeric, [integral](integral-types-table.md)|U or u|
|[ulong](ulong.md)|Unsigned, numeric, [integral](integral-types-table.md)|UL, Ul, uL, ul, LU, Lu, lU, or lu|
|[ushort](ushort.md)|Unsigned, numeric, [integral](integral-types-table.md)||

## Remarks

Expand All @@ -50,4 +50,4 @@ If a [real numerical literal](~/_csharplang/spec/lexical-structure.md#real-liter
- [Reference tables for types](reference-tables-for-types.md)
- [Default values table](default-values-table.md)
- [Value types](value-types.md)
- [Formatting numeric results table](formatting-numeric-results-table.md)
- [Formatting numeric results table](formatting-numeric-results-table.md)
118 changes: 59 additions & 59 deletions docs/csharp/language-reference/keywords/value-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ There are two kinds of value types:

A variable of a value type contains a value of the type. For example, a variable of the `int` type might contain the value `42`. This differs from a variable of a reference type, which contains a reference to an instance of the type, also known as an object. When you assign a new value to a variable of a value type, that value is copied. When you assign a new value to a variable of a reference type, the reference is copied, not the object itself.

All value types are derived implicitly from the <xref:System.ValueType?displayProperty=nameWithType>.
Unlike with reference types, you cannot derive a new type from a value type. However, like reference types, structs can implement interfaces.
All value types are derived implicitly from the <xref:System.ValueType?displayProperty=nameWithType>.

Unlike with reference types, you cannot derive a new type from a value type. However, like reference types, structs can implement interfaces.

Value type variables cannot be `null` by default. However, variables of the corresponding [nullable types](../../../csharp/programming-guide/nullable-types/index.md) can be `null`.
Each value type has an implicit default constructor that initializes the default value of that type. For information about default values of value types, see [Default values table](default-values-table.md).

Each value type has an implicit default constructor that initializes the default value of that type. For information about default values of value types, see [Default values table](default-values-table.md).

## Simple types

The *simple types* are a set of predefined struct types provided by C# and comprise the following types:
Expand All @@ -50,59 +50,59 @@ The simple types differ from other struct types in that they permit certain addi
- Constant expressions, whose operands are all simple type constants, are evaluated at compile time.

For more information, see the [Simple types](~/_csharplang/spec/types.md#simple-types) section of the [C# language specification](../language-specification/index.md).

## Initializing value types

Local variables in C# must be initialized before they are used. For example, you might declare a local variable without initialization as in the following example:
```csharp
int myInt;
```
You cannot use it before you initialize it. You can initialize it using the following statement:
```csharp
myInt = new int(); // Invoke default constructor for int type.
```
This statement is equivalent to the following statement:
```csharp
myInt = 0; // Assign an initial value, 0 in this example.
```
You can, of course, have the declaration and the initialization in the same statement as in the following examples:
```csharp
int myInt = new int();
```
–or–
```csharp
int myInt = 0;
```
Using the [new](new.md) operator calls the default constructor of the specific type and assigns the default value to the variable. In the preceding example, the default constructor assigned the value `0` to `myInt`. For more information about values assigned by calling default constructors, see [Default values table](default-values-table.md).
With user-defined types, use [new](new.md) to invoke the default constructor. For example, the following statement invokes the default constructor of the `Point` struct:
```csharp
Point p = new Point(); // Invoke default constructor for the struct.
```
After this call, the struct is considered to be definitely assigned; that is, all its members are initialized to their default values.
For more information about the `new` operator, see [new](new.md).
For information about formatting the output of numeric types, see [Formatting numeric results table](formatting-numeric-results-table.md).
Local variables in C# must be initialized before they are used. For example, you might declare a local variable without initialization as in the following example:

```csharp
int myInt;
```

You cannot use it before you initialize it. You can initialize it using the following statement:

```csharp
myInt = new int(); // Invoke default constructor for int type.
```

This statement is equivalent to the following statement:

```csharp
myInt = 0; // Assign an initial value, 0 in this example.
```

You can, of course, have the declaration and the initialization in the same statement as in the following examples:

```csharp
int myInt = new int();
```

–or–

```csharp
int myInt = 0;
```

Using the [new](new.md) operator calls the default constructor of the specific type and assigns the default value to the variable. In the preceding example, the default constructor assigned the value `0` to `myInt`. For more information about values assigned by calling default constructors, see [Default values table](default-values-table.md).

With user-defined types, use [new](new.md) to invoke the default constructor. For example, the following statement invokes the default constructor of the `Point` struct:

```csharp
Point p = new Point(); // Invoke default constructor for the struct.
```

After this call, the struct is considered to be definitely assigned; that is, all its members are initialized to their default values.

For more information about the `new` operator, see [new](new.md).

For information about formatting the output of numeric types, see [Formatting numeric results table](formatting-numeric-results-table.md).

## See also

- [C# Reference](../index.md)
- [C# Programming Guide](../../programming-guide/index.md)
- [C# Keywords](index.md)
- [Types](types.md)
- [Reference tables for types](reference-tables-for-types.md)
- [Reference Types](reference-types.md)
- [Nullable types](../../programming-guide/nullable-types/index.md)
- [C# Reference](../index.md)
- [C# Programming Guide](../../programming-guide/index.md)
- [C# Keywords](index.md)
- [Types](types.md)
- [Reference tables for types](reference-tables-for-types.md)
- [Reference Types](reference-types.md)
- [Nullable types](../../programming-guide/nullable-types/index.md)
Loading