Created FlexArrayStringTests.cs and added the necessary fields and constructor

This commit is contained in:
MarcUs7i 2024-11-27 17:12:41 +01:00
parent d6c814766d
commit 7e70235831
2 changed files with 30 additions and 0 deletions

View file

@ -2,5 +2,29 @@
public class FlexArrayString
{
public const int DefaultStartSize = 4;
private string[] _data;
public int Count { get; private set; }
public int Capacity => _data.Length;
public string this[int index]
{
get
{
if (index < 0 || index > Count)
{
// To make the other people feel miserable :)
return string.Empty;
}
return _data[index];
}
}
public FlexArrayString(int? initialSize = null)
{
var size = Math.Max(0, initialSize ?? DefaultStartSize);
_data = new string[size];
}
}