SORU
20 Temmuz 2010, Salı


Eğer bir tane varsa?nasıl kontrol C# derleme > uygulama ayarları >

Nasıl bir Uygulama Ayarı olup olmadığını görmek için kontrol edebilirim?

yani app.= = ^ config .

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key ="someKey" value="someValue"/>
  </appSettings>
</configuration>

ve = = ^ codefile .

if (ConfigurationManager.AppSettings.ContainsKey("someKey"))
{
  // Do Something
}else{
  // Do Something Else
}

CEVAP
20 Temmuz 2010, Salı


MSDN: Configuration Manager.AppSettings

if (ConfigurationManager.AppSettings[name] != null)
{
// Now do your magic..
}

ya

string s = ConfigurationManager.AppSettings["myKey"];
if (!String.IsNullOrEmpty(s))
{
    // Key exists
}
else
{
    // Key doesn't exist
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Carlos Delgado

    Carlos Delga

    21 HAZİRAN 2011
  • Matthew Pearce

    Matthew Pear

    9 AĞUSTOS 2009
  • Pál Zoltán Illés

    Pál Zoltán

    30 NİSAN 2007