Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using an indexer on Table result in error #42

Open
MBCD2000 opened this issue Oct 19, 2023 · 0 comments
Open

Using an indexer on Table result in error #42

MBCD2000 opened this issue Oct 19, 2023 · 0 comments

Comments

@MBCD2000
Copy link

MBCD2000 commented Oct 19, 2023

Thank you for this nice peace of software!

I tried to get a row from a table by indexing it, this resulted in a null:

var settingsTable= tml["Einstellungen"].AsTable;
var tableRow= settingsTable[0];

There should be a possibility to use an indexer to get the key and its value, like an Dictionary returns it.
With strings this works fine, but integers results into null, but I expected to get something 😉

I added this code to the TomlTable to fix this:

public new KeyValuePair<string, TomlNode> this[int index] { get { if (index > RawTable.Count) return new KeyValuePair<string, TomlNode>(); return RawTable.ElementAt(index); } set { if (index > RawTable.Count) return; RawTable[RawTable.ElementAt(index).Key] = value!.Value; } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant