C#: How to make sure a settings variable exists before attempting to use it from another assembly?

前端 未结 5 1904
忘了有多久
忘了有多久 2021-02-07 11:10

I have the following:

using CommonSettings = MyProject.Commons.Settings;

public class Foo
{
    public static void DoSomething(string str)
    {
        //How d         


        
5条回答
  •  再見小時候
    2021-02-07 11:55

    This is how you deal with it:

    if(CommonSettings.Default.Properties[str] != null)
    {
        //Hooray, we found it!
    }
    else
    {
        //This is a 'no go'
    }
    

提交回复
热议问题