NSoft.NFramework.Nini.Ini.IniSection.GetValue C# (CSharp) Method

GetValue() public method

public GetValue ( string key ) : string
key string
return string
        public string GetValue(string key) {
            string result = null;

            if(Contains(key)) {
                IniItem item = (IniItem)configList[key];
                result = item.Value;
            }

            return result;
        }

Usage Example

示例#1
0
        public void SaveToStream()
        {
            string     filePath = "SaveToStream.ini";
            FileStream stream   = new FileStream(filePath, FileMode.Create);

            // Create a new document and save to stream
            IniDocument doc     = new IniDocument();
            IniSection  section = new IniSection("Pets");

            section.Set("dog", "rover");
            section.Set("cat", "muffy");
            doc.Sections.Add(section);
            doc.Save(stream);
            stream.Close();

            IniDocument newDoc = new IniDocument(new FileStream(filePath,
                                                                FileMode.Open));

            section = newDoc.Sections["Pets"];
            Assert.IsNotNull(section);
            Assert.AreEqual(2, section.GetKeys().Length);
            Assert.AreEqual("rover", section.GetValue("dog"));
            Assert.AreEqual("muffy", section.GetValue("cat"));

            stream.Close();

            File.Delete(filePath);
        }
All Usage Examples Of NSoft.NFramework.Nini.Ini.IniSection::GetValue