Volatile.Read Method 
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Reads the value of a field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method.
Overloads
| Read(Boolean) | Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method. | 
| Read(Byte) | Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method. | 
| Read(Double) | Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method. | 
| Read(Int16) | Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method. | 
| Read(Int32) | Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method. | 
| Read(Int64) | Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method. | 
| Read(IntPtr) | Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method. | 
| Read(SByte) | Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method. | 
| Read(Single) | Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method. | 
| Read(UInt16) | Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method. | 
| Read(UInt32) | Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method. | 
| Read(UInt64) | Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method. | 
| Read(UIntPtr) | Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method. | 
| Read<T>(T) | Reads the object reference from the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method. | 
Read(Boolean)
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method.
public:
 static bool Read(bool % location);public static bool Read(ref bool location);public static bool Read(ref readonly bool location);static member Read : bool -> boolPublic Shared Function Read (ByRef location As Boolean) As BooleanParameters
- location
- Boolean
The field to read.
Returns
The value that was read.
Remarks
For more information, see the Volatile class.
Applies to
Read(Byte)
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method.
public:
 static System::Byte Read(System::Byte % location);public static byte Read(ref byte location);public static byte Read(ref readonly byte location);static member Read : byte -> bytePublic Shared Function Read (ByRef location As Byte) As ByteParameters
- location
- Byte
The field to read.
Returns
The value that was read.
Remarks
For more information, see the Volatile class.
Applies to
Read(Double)
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method.
public:
 static double Read(double % location);public static double Read(ref double location);public static double Read(ref readonly double location);static member Read : double -> doublePublic Shared Function Read (ByRef location As Double) As DoubleParameters
- location
- Double
The field to read.
Returns
The value that was read.
Remarks
For more information, see the Volatile class.
Applies to
Read(Int16)
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method.
public:
 static short Read(short % location);public static short Read(ref short location);public static short Read(ref readonly short location);static member Read : int16 -> int16Public Shared Function Read (ByRef location As Short) As ShortParameters
- location
- Int16
The field to read.
Returns
The value that was read.
Remarks
For more information, see the Volatile class.
Applies to
Read(Int32)
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method.
public:
 static int Read(int % location);public static int Read(ref int location);public static int Read(ref readonly int location);static member Read : int -> intPublic Shared Function Read (ByRef location As Integer) As IntegerParameters
- location
- Int32
The field to read.
Returns
The value that was read.
Remarks
For more information, see the Volatile class.
Applies to
Read(Int64)
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method.
public:
 static long Read(long % location);public static long Read(ref long location);public static long Read(ref readonly long location);static member Read : int64 -> int64Public Shared Function Read (ByRef location As Long) As LongParameters
- location
- Int64
The field to read.
Returns
The value that was read.
Remarks
For more information, see the Volatile class.
Applies to
Read(IntPtr)
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method.
public:
 static IntPtr Read(IntPtr % location);public static IntPtr Read(ref IntPtr location);public static IntPtr Read(ref readonly IntPtr location);static member Read : nativeint -> nativeintPublic Shared Function Read (ByRef location As IntPtr) As IntPtrParameters
- location
- 
				
				IntPtr
nativeint 
The field to read.
Returns
nativeint
The value that was read.
Remarks
For more information, see the Volatile class.
Applies to
Read(SByte)
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
Important
This API is not CLS-compliant.
Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method.
public:
 static System::SByte Read(System::SByte % location);[System.CLSCompliant(false)]
public static sbyte Read(ref sbyte location);[System.CLSCompliant(false)]
public static sbyte Read(ref readonly sbyte location);[<System.CLSCompliant(false)>]
static member Read : sbyte -> sbytePublic Shared Function Read (ByRef location As SByte) As SByteParameters
- location
- SByte
The field to read.
Returns
The value that was read.
- Attributes
Remarks
For more information, see the Volatile class.
Applies to
Read(Single)
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method.
public:
 static float Read(float % location);public static float Read(ref float location);public static float Read(ref readonly float location);static member Read : single -> singlePublic Shared Function Read (ByRef location As Single) As SingleParameters
- location
- Single
The field to read.
Returns
The value that was read.
Remarks
For more information, see the Volatile class.
Applies to
Read(UInt16)
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
Important
This API is not CLS-compliant.
- CLS-compliant alternative
- System.Threading.Volatile.Read(Int16)
Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method.
public:
 static System::UInt16 Read(System::UInt16 % location);[System.CLSCompliant(false)]
public static ushort Read(ref ushort location);[System.CLSCompliant(false)]
public static ushort Read(ref readonly ushort location);[<System.CLSCompliant(false)>]
static member Read : uint16 -> uint16Public Shared Function Read (ByRef location As UShort) As UShortParameters
- location
- UInt16
The field to read.
Returns
The value that was read.
- Attributes
Remarks
For more information, see the Volatile class.
Applies to
Read(UInt32)
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
Important
This API is not CLS-compliant.
- CLS-compliant alternative
- System.Threading.Volatile.Read(Int32)
Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method.
public:
 static System::UInt32 Read(System::UInt32 % location);[System.CLSCompliant(false)]
public static uint Read(ref uint location);[System.CLSCompliant(false)]
public static uint Read(ref readonly uint location);[<System.CLSCompliant(false)>]
static member Read : uint32 -> uint32Public Shared Function Read (ByRef location As UInteger) As UIntegerParameters
- location
- UInt32
The field to read.
Returns
The value that was read.
- Attributes
Remarks
For more information, see the Volatile class.
Applies to
Read(UInt64)
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
Important
This API is not CLS-compliant.
- CLS-compliant alternative
- System.Threading.Volatile.Read(Int64)
Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method.
public:
 static System::UInt64 Read(System::UInt64 % location);[System.CLSCompliant(false)]
public static ulong Read(ref ulong location);[System.CLSCompliant(false)]
public static ulong Read(ref readonly ulong location);[<System.CLSCompliant(false)>]
static member Read : uint64 -> uint64Public Shared Function Read (ByRef location As ULong) As ULongParameters
- location
- UInt64
The field to read.
Returns
The value that was read.
- Attributes
Remarks
For more information, see the Volatile class.
Applies to
Read(UIntPtr)
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
Important
This API is not CLS-compliant.
- CLS-compliant alternative
- System.Threading.Volatile.Read(IntPtr)
Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method.
public:
 static UIntPtr Read(UIntPtr % location);[System.CLSCompliant(false)]
public static UIntPtr Read(ref UIntPtr location);[System.CLSCompliant(false)]
public static UIntPtr Read(ref readonly UIntPtr location);[<System.CLSCompliant(false)>]
static member Read : unativeint -> unativeintPublic Shared Function Read (ByRef location As UIntPtr) As UIntPtrParameters
- location
- 
				
				UIntPtr
unativeint 
The field to read.
Returns
unativeint
The value that was read.
- Attributes
Remarks
For more information, see the Volatile class.
Applies to
Read<T>(T)
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
- Source:
- Volatile.cs
Reads the object reference from the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method.
public:
generic <typename T>
 where T : class static T Read(T % location);public static T Read<T>(ref T location) where T : class;public static T Read<T>(ref readonly T location) where T : class;static member Read : 'T -> 'T (requires 'T : null)Public Shared Function Read(Of T As Class) (ByRef location As T) As TType Parameters
- T
The type of field to read. This must be a reference type, not a value type.
Parameters
- location
- T
The field to read.
Returns
The reference to T that was read. This reference is the latest written by any processor in the computer, regardless of the number of processors or the state of processor cache.
Remarks
For more information, see the Volatile class.