function to get the zero-based offset of a particular String in a list of strings with optional padding after each item (e.g. 1 for null terminator)
This commit is contained in:
parent
b6f6865e7a
commit
9064e144f0
@ -27,6 +27,16 @@ namespace UniversalEditor
|
||||
{
|
||||
public static class ExtensionMethods
|
||||
{
|
||||
public static long GetItemOffset(this List<string> list, int index, int additionalPadding = 0)
|
||||
{
|
||||
long offset = 0;
|
||||
for (int i = 0; i < index; i++)
|
||||
{
|
||||
offset += list[i].Length + additionalPadding;
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
public static bool get_EndOfStream(this System.IO.Stream stream)
|
||||
{
|
||||
return (stream.Position == stream.Length);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user