Show / Hide Table of Contents

# Class NetDataReader

##### Inheritance

object
NetDataReader
NetPacketReader

###### Namespace: LiteNetLib.Utils

###### Assembly: LiteNetLib.dll

##### Syntax

    public class NetDataReader

### Constructors

#### NetDataReader()

##### Declaration

    public NetDataReader()

#### NetDataReader(NetDataWriter)

##### Declaration

    public NetDataReader(NetDataWriter writer)

##### Parameters

Type | Name | Description
--- | --- | ---
NetDataWriter | writer |

#### NetDataReader(byte[])

##### Declaration

    public NetDataReader(byte[] source)

##### Parameters

Type | Name | Description
--- | --- | ---
byte[] | source |

#### NetDataReader(byte[], int, int)

##### Declaration

    public NetDataReader(byte[] source, int offset, int maxSize)

##### Parameters

Type | Name | Description
--- | --- | ---
byte[] | source |
int | offset |
int | maxSize |

### Fields

#### _data

##### Declaration

    protected byte[] _data

##### Field Value

Type | Description
--- | ---
byte[] |

#### _dataSize

##### Declaration

    protected int _dataSize

##### Field Value

Type | Description
--- | ---
int |

#### _position

##### Declaration

    protected int _position

##### Field Value

Type | Description
--- | ---
int |

### Properties

#### AvailableBytes

##### Declaration

    public int AvailableBytes { get; }

##### Property Value

Type | Description
--- | ---
int |

#### EndOfData

##### Declaration

    public bool EndOfData { get; }

##### Property Value

Type | Description
--- | ---
bool |

#### IsNull

##### Declaration

    public bool IsNull { get; }

##### Property Value

Type | Description
--- | ---
bool |

#### Position

##### Declaration

    public int Position { get; }

##### Property Value

Type | Description
--- | ---
int |

#### RawData

##### Declaration

    public byte[] RawData { get; }

##### Property Value

Type | Description
--- | ---
byte[] |

#### RawDataSize

##### Declaration

    public int RawDataSize { get; }

##### Property Value

Type | Description
--- | ---
int |

#### UserDataOffset

##### Declaration

    public int UserDataOffset { get; }

##### Property Value

Type | Description
--- | ---
int |

#### UserDataSize

##### Declaration

    public int UserDataSize { get; }

##### Property Value

Type | Description
--- | ---
int |

### Methods

#### Clear()

##### Declaration

    public void Clear()

#### Get(out bool)

##### Declaration

    public void Get(out bool result)

##### Parameters

Type | Name | Description
--- | --- | ---
bool | result |

#### Get(out byte)

##### Declaration

    public void Get(out byte result)

##### Parameters

Type | Name | Description
--- | --- | ---
byte | result |

#### Get(out char)

##### Declaration

    public void Get(out char result)

##### Parameters

Type | Name | Description
--- | --- | ---
char | result |

#### Get(out double)

##### Declaration

    public void Get(out double result)

##### Parameters

Type | Name | Description
--- | --- | ---
double | result |

#### Get(out short)

##### Declaration

    public void Get(out short result)

##### Parameters

Type | Name | Description
--- | --- | ---
short | result |

#### Get(out int)

##### Declaration

    public void Get(out int result)

##### Parameters

Type | Name | Description
--- | --- | ---
int | result |

#### Get(out long)

##### Declaration

    public void Get(out long result)

##### Parameters

Type | Name | Description
--- | --- | ---
long | result |

#### Get(out IPEndPoint)

##### Declaration

    public void Get(out IPEndPoint result)

##### Parameters

Type | Name | Description
--- | --- | ---
IPEndPoint | result |

#### Get(out sbyte)

##### Declaration

    public void Get(out sbyte result)

##### Parameters

Type | Name | Description
--- | --- | ---
sbyte | result |

#### Get(out float)

##### Declaration

    public void Get(out float result)

##### Parameters

Type | Name | Description
--- | --- | ---
float | result |

#### Get(out string)

##### Declaration

    public void Get(out string result)

##### Parameters

Type | Name | Description
--- | --- | ---
string | result |

#### Get(out string, int)

##### Declaration

    public void Get(out string result, int maxLength)

##### Parameters

Type | Name | Description
--- | --- | ---
string | result |
int | maxLength |

#### Get(out ushort)

##### Declaration

    public void Get(out ushort result)

##### Parameters

Type | Name | Description
--- | --- | ---
ushort | result |

#### Get(out uint)

##### Declaration

    public void Get(out uint result)

##### Parameters

Type | Name | Description
--- | --- | ---
uint | result |

#### Get(out ulong)

##### Declaration

    public void Get(out ulong result)

##### Parameters

Type | Name | Description
--- | --- | ---
ulong | result |

#### GetArray<T>(ushort)

##### Declaration

    public T[] GetArray<T>(ushort size)

##### Parameters

Type | Name | Description
--- | --- | ---
ushort | size |

##### Returns

Type | Description
--- | ---
T[] |

##### Type Parameters

Name | Description
--- | ---
T |

#### GetBool()

##### Declaration

    public bool GetBool()

##### Returns

Type | Description
--- | ---
bool |

#### GetBoolArray()

##### Declaration

    public bool[] GetBoolArray()

##### Returns

Type | Description
--- | ---
bool[] |

#### GetByte()

##### Declaration

    public byte GetByte()

##### Returns

Type | Description
--- | ---
byte |

#### GetBytes(byte[], int)

##### Declaration

    public void GetBytes(byte[] destination, int count)

##### Parameters

Type | Name | Description
--- | --- | ---
byte[] | destination |
int | count |

#### GetBytes(byte[], int, int)

##### Declaration

    public void GetBytes(byte[] destination, int start, int count)

##### Parameters

Type | Name | Description
--- | --- | ---
byte[] | destination |
int | start |
int | count |

#### GetBytesSegment(int)

##### Declaration

    public ArraySegment<byte> GetBytesSegment(int count)

##### Parameters

Type | Name | Description
--- | --- | ---
int | count |

##### Returns

Type | Description
--- | ---
ArraySegment<byte> |

#### GetBytesWithLength()

##### Declaration

    public byte[] GetBytesWithLength()

##### Returns

Type | Description
--- | ---
byte[] |

#### GetChar()

##### Declaration

    public char GetChar()

##### Returns

Type | Description
--- | ---
char |

#### GetDouble()

##### Declaration

    public double GetDouble()

##### Returns

Type | Description
--- | ---
double |

#### GetDoubleArray()

##### Declaration

    public double[] GetDoubleArray()

##### Returns

Type | Description
--- | ---
double[] |

#### GetFloat()

##### Declaration

    public float GetFloat()

##### Returns

Type | Description
--- | ---
float |

#### GetFloatArray()

##### Declaration

    public float[] GetFloatArray()

##### Returns

Type | Description
--- | ---
float[] |

#### GetInt()

##### Declaration

    public int GetInt()

##### Returns

Type | Description
--- | ---
int |

#### GetIntArray()

##### Declaration

    public int[] GetIntArray()

##### Returns

Type | Description
--- | ---
int[] |

#### GetLong()

##### Declaration

    public long GetLong()

##### Returns

Type | Description
--- | ---
long |

#### GetLongArray()

##### Declaration

    public long[] GetLongArray()

##### Returns

Type | Description
--- | ---
long[] |

#### GetNetEndPoint()

##### Declaration

    public IPEndPoint GetNetEndPoint()

##### Returns

Type | Description
--- | ---
IPEndPoint |

#### GetRemainingBytes()

##### Declaration

    public byte[] GetRemainingBytes()

##### Returns

Type | Description
--- | ---
byte[] |

#### GetRemainingBytesSegment()

##### Declaration

    public ArraySegment<byte> GetRemainingBytesSegment()

##### Returns

Type | Description
--- | ---
ArraySegment<byte> |

#### GetRemainingBytesSpan()

##### Declaration

    public ReadOnlySpan<byte> GetRemainingBytesSpan()

##### Returns

Type | Description
--- | ---
ReadOnlySpan<byte> |

#### GetSByte()

##### Declaration

    public sbyte GetSByte()

##### Returns

Type | Description
--- | ---
sbyte |

#### GetSBytesWithLength()

##### Declaration

    public sbyte[] GetSBytesWithLength()

##### Returns

Type | Description
--- | ---
sbyte[] |

#### GetShort()

##### Declaration

    public short GetShort()

##### Returns

Type | Description
--- | ---
short |

#### GetShortArray()

##### Declaration

    public short[] GetShortArray()

##### Returns

Type | Description
--- | ---
short[] |

#### GetString()

##### Declaration

    public string GetString()

##### Returns

Type | Description
--- | ---
string |

#### GetString(int)

Note that "maxLength" only limits the number of characters in a string, not its size in bytes.

##### Declaration

    public string GetString(int maxLength)

##### Parameters

Type | Name | Description
--- | --- | ---
int | maxLength |

##### Returns

Type | Description
--- | ---
string | "string.Empty" if value > "maxLength"

#### GetStringArray()

##### Declaration

    public string[] GetStringArray()

##### Returns

Type | Description
--- | ---
string[] |

#### GetStringArray(int)

Note that "maxStringLength" only limits the number of characters in a string, not its size in bytes. Strings that exceed this parameter are returned as empty

##### Declaration

    public string[] GetStringArray(int maxStringLength)

##### Parameters

Type | Name | Description
--- | --- | ---
int | maxStringLength |

##### Returns

Type | Description
--- | ---
string[] |

#### GetUInt()

##### Declaration

    public uint GetUInt()

##### Returns

Type | Description
--- | ---
uint |

#### GetUIntArray()

##### Declaration

    public uint[] GetUIntArray()

##### Returns

Type | Description
--- | ---
uint[] |

#### GetULong()

##### Declaration

    public ulong GetULong()

##### Returns

Type | Description
--- | ---
ulong |

#### GetULongArray()

##### Declaration

    public ulong[] GetULongArray()

##### Returns

Type | Description
--- | ---
ulong[] |

#### GetUShort()

##### Declaration

    public ushort GetUShort()

##### Returns

Type | Description
--- | ---
ushort |

#### GetUShortArray()

##### Declaration

    public ushort[] GetUShortArray()

##### Returns

Type | Description
--- | ---
ushort[] |

#### Get<T>()

##### Declaration

    public T Get<T>() where T : struct, INetSerializable

##### Returns

Type | Description
--- | ---
T |

##### Type Parameters

Name | Description
--- | ---
T |

#### Get<T>(Func<T>)

##### Declaration

    public T Get<T>(Func<T> constructor) where T : class, INetSerializable

##### Parameters

Type | Name | Description
--- | --- | ---
Func<T> | constructor |

##### Returns

Type | Description
--- | ---
T |

##### Type Parameters

Name | Description
--- | ---
T |

#### Get<T>(out T)

##### Declaration

    public void Get<T>(out T result) where T : struct, INetSerializable

##### Parameters

Type | Name | Description
--- | --- | ---
T | result |

##### Type Parameters

Name | Description
--- | ---
T |

#### Get<T>(out T, Func<T>)

##### Declaration

    public void Get<T>(out T result, Func<T> constructor) where T : class, INetSerializable

##### Parameters

Type | Name | Description
--- | --- | ---
T | result |
Func<T> | constructor |

##### Type Parameters

Name | Description
--- | ---
T |

#### PeekBool()

##### Declaration

    public bool PeekBool()

##### Returns

Type | Description
--- | ---
bool |

#### PeekByte()

##### Declaration

    public byte PeekByte()

##### Returns

Type | Description
--- | ---
byte |

#### PeekChar()

##### Declaration

    public char PeekChar()

##### Returns

Type | Description
--- | ---
char |

#### PeekDouble()

##### Declaration

    public double PeekDouble()

##### Returns

Type | Description
--- | ---
double |

#### PeekFloat()

##### Declaration

    public float PeekFloat()

##### Returns

Type | Description
--- | ---
float |

#### PeekInt()

##### Declaration

    public int PeekInt()

##### Returns

Type | Description
--- | ---
int |

#### PeekLong()

##### Declaration

    public long PeekLong()

##### Returns

Type | Description
--- | ---
long |

#### PeekSByte()

##### Declaration

    public sbyte PeekSByte()

##### Returns

Type | Description
--- | ---
sbyte |

#### PeekShort()

##### Declaration

    public short PeekShort()

##### Returns

Type | Description
--- | ---
short |

#### PeekString()

##### Declaration

    public string PeekString()

##### Returns

Type | Description
--- | ---
string |

#### PeekString(int)

Note that "maxLength" only limits the number of characters in a string, not its size in bytes.

##### Declaration

    public string PeekString(int maxLength)

##### Parameters

Type | Name | Description
--- | --- | ---
int | maxLength |

##### Returns

Type | Description
--- | ---
string |

#### PeekUInt()

##### Declaration

    public uint PeekUInt()

##### Returns

Type | Description
--- | ---
uint |

#### PeekULong()

##### Declaration

    public ulong PeekULong()

##### Returns

Type | Description
--- | ---
ulong |

#### PeekUShort()

##### Declaration

    public ushort PeekUShort()

##### Returns

Type | Description
--- | ---
ushort |

#### SetPosition(int)

##### Declaration

    public void SetPosition(int position)

##### Parameters

Type | Name | Description
--- | --- | ---
int | position |

#### SetSource(NetDataWriter)

##### Declaration

    public void SetSource(NetDataWriter dataWriter)

##### Parameters

Type | Name | Description
--- | --- | ---
NetDataWriter | dataWriter |

#### SetSource(byte[])

##### Declaration

    public void SetSource(byte[] source)

##### Parameters

Type | Name | Description
--- | --- | ---
byte[] | source |

#### SetSource(byte[], int, int)

##### Declaration

    public void SetSource(byte[] source, int offset, int maxSize)

##### Parameters

Type | Name | Description
--- | --- | ---
byte[] | source |
int | offset |
int | maxSize |

#### SkipBytes(int)

##### Declaration

    public void SkipBytes(int count)

##### Parameters

Type | Name | Description
--- | --- | ---
int | count |

#### TryGetBool(out bool)

##### Declaration

    public bool TryGetBool(out bool result)

##### Parameters

Type | Name | Description
--- | --- | ---
bool | result |

##### Returns

Type | Description
--- | ---
bool |

#### TryGetByte(out byte)

##### Declaration

    public bool TryGetByte(out byte result)

##### Parameters

Type | Name | Description
--- | --- | ---
byte | result |

##### Returns

Type | Description
--- | ---
bool |

#### TryGetBytesWithLength(out byte[])

##### Declaration

    public bool TryGetBytesWithLength(out byte[] result)

##### Parameters

Type | Name | Description
--- | --- | ---
byte[] | result |

##### Returns

Type | Description
--- | ---
bool |

#### TryGetChar(out char)

##### Declaration

    public bool TryGetChar(out char result)

##### Parameters

Type | Name | Description
--- | --- | ---
char | result |

##### Returns

Type | Description
--- | ---
bool |

#### TryGetDouble(out double)

##### Declaration

    public bool TryGetDouble(out double result)

##### Parameters

Type | Name | Description
--- | --- | ---
double | result |

##### Returns

Type | Description
--- | ---
bool |

#### TryGetFloat(out float)

##### Declaration

    public bool TryGetFloat(out float result)

##### Parameters

Type | Name | Description
--- | --- | ---
float | result |

##### Returns

Type | Description
--- | ---
bool |

#### TryGetInt(out int)

##### Declaration

    public bool TryGetInt(out int result)

##### Parameters

Type | Name | Description
--- | --- | ---
int | result |

##### Returns

Type | Description
--- | ---
bool |

#### TryGetLong(out long)

##### Declaration

    public bool TryGetLong(out long result)

##### Parameters

Type | Name | Description
--- | --- | ---
long | result |

##### Returns

Type | Description
--- | ---
bool |

#### TryGetSByte(out sbyte)

##### Declaration

    public bool TryGetSByte(out sbyte result)

##### Parameters

Type | Name | Description
--- | --- | ---
sbyte | result |

##### Returns

Type | Description
--- | ---
bool |

#### TryGetShort(out short)

##### Declaration

    public bool TryGetShort(out short result)

##### Parameters

Type | Name | Description
--- | --- | ---
short | result |

##### Returns

Type | Description
--- | ---
bool |

#### TryGetString(out string)

##### Declaration

    public bool TryGetString(out string result)

##### Parameters

Type | Name | Description
--- | --- | ---
string | result |

##### Returns

Type | Description
--- | ---
bool |

#### TryGetStringArray(out string[])

##### Declaration

    public bool TryGetStringArray(out string[] result)

##### Parameters

Type | Name | Description
--- | --- | ---
string[] | result |

##### Returns

Type | Description
--- | ---
bool |

#### TryGetUInt(out uint)

##### Declaration

    public bool TryGetUInt(out uint result)

##### Parameters

Type | Name | Description
--- | --- | ---
uint | result |

##### Returns

Type | Description
--- | ---
bool |

#### TryGetULong(out ulong)

##### Declaration

    public bool TryGetULong(out ulong result)

##### Parameters

Type | Name | Description
--- | --- | ---
ulong | result |

##### Returns

Type | Description
--- | ---
bool |

#### TryGetUShort(out ushort)

##### Declaration

    public bool TryGetUShort(out ushort result)

##### Parameters

Type | Name | Description
--- | --- | ---
ushort | result |

##### Returns

Type | Description
--- | ---
bool |