Table of Contents

Class Index

Namespace
Supabase.Postgrest
Assembly
Supabase.Postgrest.dll

Represent a type can be used to index a collection either from the start or the end.

public class Index : IEquatable<Index>
Inheritance
Index
Implements
Inherited Members

Remarks

Index is used by the C# compiler to support the new index syntax

int[] someArray = new int[5] { 1, 2, 3, 4, 5 } ;
int lastElement = someArray[^1]; // lastElement = 5

Constructors

Index(int, bool)

Construct an Index using a value and indicating if the index is from the start or from the end.

public Index(int value, bool fromEnd = false)

Parameters

value int

The index value. it has to be zero or positive number.

fromEnd bool

Indicating if the index is from the start or from the end.

Remarks

If the Index constructed from the end, index value 1 means pointing at the last element and index value 0 means pointing at beyond last element.

Properties

End

Create an Index pointing at beyond last element.

public static Index End { get; }

Property Value

Index

IsFromEnd

Indicates whether the index is from the start or the end.

public bool IsFromEnd { get; }

Property Value

bool

Start

Create an Index pointing at first element.

public static Index Start { get; }

Property Value

Index

Value

Returns the index value.

public int Value { get; }

Property Value

int

Methods

Equals(Index)

Indicates whether the current Index object is equal to another Index object.

public bool Equals(Index other)

Parameters

other Index

An object to compare with this object

Returns

bool

Equals(object?)

Indicates whether the current Index object is equal to another object of the same type.

public override bool Equals(object? value)

Parameters

value object

An object to compare with this object

Returns

bool

FromEnd(int)

Create an Index from the end at the position indicated by the value.

public static Index FromEnd(int value)

Parameters

value int

The index value from the end.

Returns

Index

FromStart(int)

Create an Index from the start at the position indicated by the value.

public static Index FromStart(int value)

Parameters

value int

The index value from the start.

Returns

Index

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

GetOffset(int)

Calculate the offset from the start using the giving collection length.

public int GetOffset(int length)

Parameters

length int

The length of the collection that the Index will be used with. length has to be a positive value

Returns

int

Remarks

For performance reason, we don't validate the input length parameter and the returned offset value against negative values. we don't validate either the returned offset is greater than the input length. It is expected Index will be used with collections which always have non negative length/count. If the returned offset is negative and then used to index a collection will get out of range exception which will be same affect as the validation.

ToString()

Converts the value of the current Index object to its equivalent string representation.

public override string ToString()

Returns

string

Operators

implicit operator Index(int)

Converts integer number to an Index.

public static implicit operator Index(int value)

Parameters

value int

Returns

Index