question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Check if section / key exist

See original GitHub issue

Hey,

Is there any ways to check easily if a section, or a key exist? Included into this awesome libs, or on my side?

EDIT: Found my issue. I got an error on: bool move = conf["Settings"]["move"].BoolValue saying the instance isn’t define to an object.

I fixed it on my side by making a weird workaround, such as: bool move = Convert.ToBoolean(conf["Settings"]["move"].StringValue);

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cemderviscommented, Apr 11, 2016

Hey there! Sure, you can check if a section or setting exists using the Contains method. The Configuration class has a Contains(string sectionName) and Contains(Section section) method. The Section class also has these methods, but for settings.

Could you explain the error please?

bool move = conf["Settings"]["move"].BoolValue

What exactly is not working here?

Cheers!

0reactions
cemderviscommented, Apr 11, 2016

Alright, the new version (1.5.3) is up. Cheers! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Check if a given key already exists in a dictionary
I wanted to test if a key exists in a dictionary before updating the value for the key. I wrote the following code:...
Read more >
How to check if a key exists in a Python dictionary
has_key method. The has_key method returns true if a given key is available in the dictionary; otherwise, it returns false.
Read more >
Check whether given Key already exists in a Python ...
Check If Key Exists using has_key() method ... Using has_key() method returns true if a given key is available in the dictionary, otherwise,...
Read more >
Check if Key Exists in Dictionary Python
You can check if a key exists in a dictionary in Python using Python in keyword. This operator returns True if the key...
Read more >
Check Whether a Given Key Already Exists in a Dictionary ...
Therefore, it is a safe practice to check whether a given key already exists in the dictionary or not before trying to get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found