title: Foreach loop to check the empty string and assign it a value c#
body: <p>I dont much idea about Foreach Loop</p>
  
  <p>I have 4 String Variables and i am storing the encrypted values from app.config in those varialbles.My Work is to Detect if there is data in those 4 variables.Even if one doesnt have values i want to pass a default encrypted values to it.I started doing like this......</p>
  
  <pre><code>string EncValue = oEncrypt.EncryptBase64String("NO Data Found");
  UpdateOrCreateAppSetting("UserName", ref MPScmUserName);
  UpdateOrCreateAppSetting("Password", ref MPScmPassword);
  UpdateOrCreateAppSetting("DBUserName", ref MPDbUserName);
  UpdateOrCreateAppSetting("DBPassword", ref MPDbPassword);
  var list5 = from docs in doc1.Descendants("appender").Elements()
                                              where docs.Name == "file"
                                              select docs;
  var element5 = list5.FirstOrDefault();
  MPLoadAppConfig = appConfigFile1;
  MPErrorLog = element5.Attribute("value").Value;
  
  string[] namesArray = new string[] {
           MPScmUserName,MPScmPassword,MPDbUserName,MPDbPassword};
  
  foreach (string i in namesArray)
  {
      if (i is string)
      {
          if (i == "")
          {
              i = EncValue.ToString();
          }
      }
  }
  </code></pre>
  
  <p>How should i assign default encrypted value to the strings in that array which is a empty string. Please Help me.... </p>