当前位置: 首页>>代码示例>>C#>>正文


C# StringSet.Add方法代码示例

本文整理汇总了C#中StringSet.Add方法的典型用法代码示例。如果您正苦于以下问题:C# StringSet.Add方法的具体用法?C# StringSet.Add怎么用?C# StringSet.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringSet的用法示例。


在下文中一共展示了StringSet.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Enumerate

        public void Enumerate()
        {
            StringSet ss = new StringSet();

            int i = 0;
            foreach (string s in ss)
            {
                i++;
                Console.WriteLine(s);
            }
            Assert.AreEqual(0, i);

            ss.Add("bloo");
            ss.Add("foo");
            ss.Add("bar");
            foreach (string s in ss)
            {
                i++;
                Console.WriteLine(s);
            }
            Assert.AreEqual(3, i);
            string[] arr = ss.GetStrings();
            Array.Sort(arr);
            Assert.AreEqual("bar", arr[0]);
            Assert.AreEqual("bloo", arr[1]);
            Assert.AreEqual("foo", arr[2]);
            Assert.AreEqual(3, arr.Length);
        }
开发者ID:eNoise,项目名称:cyclops-chat,代码行数:28,代码来源:StringSet.cs

示例2: ShouldCount

 public void ShouldCount()
 {
     var stringSet = new StringSet();
     stringSet.Add("Test");
     stringSet.Add("Test");
     stringSet.Add("Test");
     Assert.AreEqual(3, stringSet.Count);
     
 }
开发者ID:david--liu,项目名称:code_kata,代码行数:9,代码来源:StringSetTest.cs

示例3: ShouldClearTheSet

 public void ShouldClearTheSet()
 {
     var stringSet = new StringSet();
     stringSet.Add("Test");
     stringSet.Add("Test");
     stringSet.Add("Test");
     stringSet.Clear();
     Assert.AreEqual(0, stringSet.Count);
     
 }
开发者ID:david--liu,项目名称:code_kata,代码行数:10,代码来源:StringSetTest.cs

示例4: ShouldEnumerate

 public void ShouldEnumerate()
 {
     var stringSet = new StringSet();
     stringSet.Add("Test");
     stringSet.Add("Test");
     stringSet.Add("Test");
     foreach (var test in stringSet)
     {
         Assert.IsTrue(stringSet.Contains(test));
     }
 }
开发者ID:david--liu,项目名称:code_kata,代码行数:11,代码来源:StringSetTest.cs

示例5: ShouldRemoveAndContainsReturnFalse

 public void ShouldRemoveAndContainsReturnFalse()
 {
     var stringSet = new StringSet();
     stringSet.Add("Test");
     Assert.IsTrue(stringSet.Contains("Test"));
     stringSet.Remove("Test");
     Assert.IsFalse(stringSet.Contains("Test"));
 }
开发者ID:david--liu,项目名称:code_kata,代码行数:8,代码来源:StringSetTest.cs

示例6: Add

        public void Add()
        {
            StringSet ss = new StringSet();
            ss.Add("foo");
            ss.Add("foo");
            ss.Add("bar");
            Assert.IsTrue(ss["foo"]);
            Assert.AreEqual(2, ss.Count);
            Assert.AreEqual("foo\r\nbar\r\n", ss.ToString());
            ss.Remove("bar");
            Assert.AreEqual(1, ss.Count);
            Assert.IsFalse(ss["fool"]);

            ss = new StringSet(new string[] { "foo", "bar"});
            ss.Add(new StringSet("baz"));
            Assert.AreEqual(3, ss.Count);
        }
开发者ID:krbysn,项目名称:jabber-net,代码行数:17,代码来源:StringSet.cs

示例7: ShouldIntersect

        public void ShouldIntersect()
        {
            var set1 = new StringSet();
            var set2 = new StringSet();
            set1.Add("Test1");
            set1.Add("Common1");
            set1.Add("Common2");
            set2.Add("Common1");
            set2.Add("Common2");
            set2.Add("Test2");


            StringSet intersect = set1.Intersect(set2);

            Assert.AreEqual(2, intersect.Count);

            Assert.IsTrue(intersect.Contains("Common1"));
            Assert.IsTrue(intersect.Contains("Common2"));
            
        }
开发者ID:david--liu,项目名称:code_kata,代码行数:20,代码来源:StringSetTest.cs

示例8: ComputeGroupedExpectedSetForState

 internal static StringSet ComputeGroupedExpectedSetForState(Grammar grammar, ParserState state)
 {
     var terms = new TerminalSet();
       terms.UnionWith(state.ExpectedTerminals);
       var result = new StringSet();
       //Eliminate no-report terminals
       foreach(var group in grammar.TermReportGroups)
     if (group.GroupType == TermReportGroupType.DoNotReport)
     terms.ExceptWith(group.Terminals);
       //Add normal and operator groups
       foreach(var group in grammar.TermReportGroups)
     if((group.GroupType == TermReportGroupType.Normal || group.GroupType == TermReportGroupType.Operator) &&
      terms.Overlaps(group.Terminals)) {
       result.Add(group.Alias);
       terms.ExceptWith(group.Terminals);
     }
       //Add remaining terminals "as is"
       foreach(var terminal in terms)
     result.Add(terminal.ErrorAlias);
       return result;
 }
开发者ID:guillaume86,项目名称:vsLua,代码行数:21,代码来源:CoreParser_ErrorHandling.cs

示例9: Merge

        public void Merge()
        {
            StringSet ss = new StringSet();
            ss.Add("foo");
            StringSet so = new StringSet();
            so.Add("bar");
            so.Add("baz");
            ss.Add(so);
            Assert.AreEqual(3, ss.Count);

            so = new StringSet();
            so.Add("boo");
            so.Add("baz");
            ss.Add(so);
            Assert.AreEqual(4, ss.Count);

            ss.Remove(so);
            Assert.AreEqual(2, ss.Count);
            Assert.IsTrue(ss["foo"]);
            Assert.IsTrue(ss["bar"]);
            Assert.IsFalse(ss["boo"]);
            Assert.IsFalse(ss["baz"]);
            Assert.IsFalse(ss["bloo"]);
        }
开发者ID:krbysn,项目名称:jabber-net,代码行数:24,代码来源:StringSet.cs

示例10: ShouldUnionTwoSet

        public void ShouldUnionTwoSet()
        {
            var set1 = new StringSet();
            var set2 = new StringSet();
            set1.Add("Test1");
            set2.Add("Test2");


            StringSet union = set1.Union(set2);

            Assert.AreEqual(2, union.Count);

            Assert.IsTrue( union.Contains("Test1"));
            Assert.IsTrue( union.Contains("Test2"));
        }
开发者ID:david--liu,项目名称:code_kata,代码行数:15,代码来源:StringSetTest.cs

示例11: Null

 public void Null()
 {
     StringSet ss = new StringSet();
     ss.Add((string)null);
 }
开发者ID:krbysn,项目名称:jabber-net,代码行数:5,代码来源:StringSet.cs

示例12: LoadStringSet

        private static void LoadStringSet(StringSet set, XmlReader reader)
        {
            reader.ReadStartElement(PROPERTY_ID);

            while (reader.IsStartElement(ITEM_ID))
            {
                string item;
                bool isEmptyItem;

                isEmptyItem = reader.IsEmptyElement;
                reader.ReadStartElement();
                item = reader.ReadString();
                set.Add(item);
                if (!isEmptyItem) reader.ReadEndElement();
            }
        }
开发者ID:blinds52,项目名称:driver-utilities,代码行数:16,代码来源:PropertyBagExtensionMethods.cs

示例13: ShouldAddStringAndContainsReturnTrue

 public void ShouldAddStringAndContainsReturnTrue()
 {
     var stringSet = new StringSet();
     stringSet.Add("Test");
     Assert.IsTrue(stringSet.Contains("Test"));
 }
开发者ID:david--liu,项目名称:code_kata,代码行数:6,代码来源:StringSetTest.cs

示例14: CheckAliases

 protected void CheckAliases(TranslationContext context, IEnumerable<Expression> outExpressions)
 {
     var sqlExpressions = outExpressions.OfType<SqlExpression>().ToList();
       var allNames = new StringSet();
       foreach(var outExpr in sqlExpressions) {
     string outName = null;
     var col = outExpr as ColumnExpression;
     if (col != null) {
       //if (isView) col.Alias = col.Name;
       outName = col.Alias ?? col.Name;
     }
     var needsAlias = outName != null && allNames.Contains(outName);
     if(outName != null)
       allNames.Add(outName);
     if(needsAlias)
       outExpr.Alias = CreateDefaultAlias(outExpr, allNames);
       }//foreach outExpr
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:18,代码来源:_LinqEngine.cs

示例15: BuildApprovedFunctionsStringSet

 private static StringSet BuildApprovedFunctionsStringSet()
 {
     var result = new StringSet();
     result.Add("_TlgWrite");
     return result;
 }
开发者ID:michaelcfanning,项目名称:binskim,代码行数:6,代码来源:DoNotDisableStackProtectionForFunctions.cs


注:本文中的StringSet.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。