Class ListExtensions
- Namespace
- Tripous
- Assembly
- Tripous.dll
Extensions
public static class ListExtensions
- Inheritance
-
ListExtensions
- Inherited Members
Methods
AsArray(IList)
Returns the content of List as an object array.
public static object[] AsArray(this IList List)
Parameters
ListIList
Returns
- object[]
AsTextLines(IList<string>)
Returns the content of a generic string list as a string
public static string AsTextLines(this IList<string> List)
Parameters
Returns
CanMove(IList, int, bool)
Returns true if item can change position.
NOTE: Down = true means towards to 0, where false means towards to List.Count
public static bool CanMove(this IList List, int Index, bool Down)
Parameters
Returns
CanMove(IList, object, bool)
Returns true if item can change position.
public static bool CanMove(this IList List, object Obj, bool Down)
Parameters
Returns
CommaText(IList<string>, bool)
Gets the whole content of the List as a single line of text, where each line ends with a comma (,)
public static string CommaText(this IList<string> List, bool WithLineBreaks = false)
Parameters
Returns
ContainsText(IList<string>, string)
Returns trur if Value exists in List, case insensitively.
public static bool ContainsText(this IList<string> List, string Value)
Parameters
Returns
Exchange(IList, int, int)
Exchanges source to source positions.
public static void Exchange(this IList List, int SourceIndex, int DestIndex)
Parameters
Exchange(IList, object, object)
Exchanges source to source positions.
public static void Exchange(this IList List, object Source, object Dest)
Parameters
GetKeyValuesList(IList<object>, int, bool)
Used in constructing SQL statements that contain a WHERE clause of the type
where FIELD_NAME in (...)
This method limits the number of elements inside the in (...) according to the passed in ModValue, in order to avoid problems with database servers that have such a limit.
It returns a string array where each element contains no more than ModValue values from SourceList.
public static string[] GetKeyValuesList(this IList<object> SourceList, int ModValue, bool DiscardBelowZeroes)
Parameters
Returns
- string[]
GetKeyValuesList(IList<object>, string, int, bool)
Used in constructing SQL statements that contain a WHERE clause of the type
where FIELD_NAME in (...)
This method limits the number of elements inside the in (...) according to the passed in ModValue, in order to avoid problems with database servers that have such a limit.
It returns a string array where each element contains no more than ModValue values from SourceList.
public static string[] GetKeyValuesList(this IList<object> SourceList, string FieldName, int ModValue, bool DiscardBelowZeroes)
Parameters
Returns
- string[]
IndexOfText(IList<string>, string)
Returns the index of Value in List, case insensitively, if exists, else -1.
public static int IndexOfText(this IList<string> List, string Value)
Parameters
Returns
IsValidIndex(IList, int)
Returns true if Index is in the range 0..List.Count - 1
public static bool IsValidIndex(this IList List, int Index)
Parameters
Returns
LoadFromFile(IList, string)
Loads List from FileName
public static void LoadFromFile(this IList List, string FileName)
Parameters
Move(IList, int, bool)
Moves item a position up or down. Returns true if item can change position.
public static bool Move(this IList List, int Index, bool Down)
Parameters
Returns
Move(IList, object, bool)
Moves item a position up or down. Returns true if item can change position.
public static bool Move(this IList List, object Obj, bool Down)
Parameters
Returns
SaveToFile(IList, string)
Saves List to FileName
public static void SaveToFile(this IList List, string FileName)
Parameters
Split<T>(IEnumerable<T>, int)
Splits a sequence into chunks of a defined size.
int[] numbers = { 1, 2, 3, 4, 5, 6, 7 };
var NumberLists = Split(numbers, 3); // results in 3 lists as {1, 2, 3}, {4, 5, 6}, {7}
public static List<List<T>> Split<T>(this IEnumerable<T> Source, int ChunkSize)
Parameters
SourceIEnumerable<T>ChunkSizeint
Returns
Type Parameters
T
ToDataTable<T>(IList<T>)
Converts a generic list to DataTable.
Property names of the list element type become column names in the DataTable.
public static DataTable ToDataTable<T>(this IList<T> SourceList)
Parameters
SourceListIList<T>
Returns
Type Parameters
T
ToDictionary(IList<string>)
Returns a specified string list as a dictionary.
Each string in the list must contain an equal sign character, e.g. Key=Value, for this to succeed.
public static Dictionary<string, string> ToDictionary(this IList<string> SourceList)