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


C# System.Collections.Generic.Dictionary.Add方法代码示例

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


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

示例1: DecodePacket

 protected override bool DecodePacket(MessageStructure reader, MessageHead head)
 {
     responsePack = ProtoBufUtils.Deserialize<Response1010Pack>(netReader.Buffer);
     string responseDataInfo = "";
     responseDataInfo = "request :" + Game.Utils.JsonHelper.prettyJson<Request1010Pack>(req) + "\n";
     responseDataInfo += "response:" + Game.Utils.JsonHelper.prettyJson<Response1010Pack>(responsePack) + "\n";
     DecodePacketInfo = responseDataInfo;
     int childStepId = getChild(1010);
     System.Console.WriteLine("childStepID:" + childStepId);
     if (childStepId > 0)
     {
         System.Collections.Generic.Dictionary<string, string> dic = new System.Collections.Generic.Dictionary<string, string>();
         /*
           req.UserID = GetParamsData("UserID", req.UserID);
         req.identify = GetParamsData("identify", req.identify);
         req.version = GetParamsData("version", req.version);
         req.the3rdUserID = GetParamsData("the3rdUserID", req.the3rdUserID);
         req.happyPoint = GetParamsData("happyPoint", req.happyPoint);
         req.Rate = GetParamsData("Rate", req.Rate);
         req.index = GetParamsData("index", req.index);
         req.strThe3rdUserID = GetParamsData("strThe3rdUserID", req.strThe3rdUserID);
         req.typeUser = GetParamsData("typeUser", req.typeUser);
          */
         dic.Add("UserID", req.UserID.ToString());
         dic.Add("index", responsePack.index.ToString());
         dic.Add("the3rdUserID", req.the3rdUserID.ToString());
         dic.Add("strThe3rdUserID", req.strThe3rdUserID);
        SetChildStep(childStepId.ToString(), _setting,dic);
     }
     return true;
 }
开发者ID:guccang,项目名称:autoTest,代码行数:31,代码来源:Step1010.cs

示例2: getShortestDistance

        //also reference to Algorithm.TreeAndGraph.Floyd and Algorithm.TreeAndGraph.Dijkstra
        public static int getShortestDistance(TreeAndGraph.GraphNode start, TreeAndGraph.GraphNode end)
        {
            System.Collections.Generic.Dictionary<int, System.Collections.Generic.List<TreeAndGraph.GraphNode>> tab
                = new System.Collections.Generic.Dictionary<int, System.Collections.Generic.List<TreeAndGraph.GraphNode>>();
            System.Collections.Generic.List<TreeAndGraph.GraphNode> list = new System.Collections.Generic.List<TreeAndGraph.GraphNode>();
            int count = 1;
            list.Add(start);
            tab.Add(count, list);
            while (true)
            {
                System.Collections.Generic.List<TreeAndGraph.GraphNode> gn_list = tab[count];
                ++count;
                if (!tab.ContainsKey(count))
                {
                    list = new System.Collections.Generic.List<TreeAndGraph.GraphNode>();
                    tab.Add(count, list);
                }
                foreach (TreeAndGraph.GraphNode gn in gn_list)
                {

                    foreach (TreeAndGraph.GraphNode node in gn.Nodes)
                    {
                        if (node == end)
                        {
                            return count;
                        }

                        tab[count].Add(node);
                    }
                }
            }
        }
开发者ID:Sanqiang,项目名称:Algorithm-Win,代码行数:33,代码来源:Q31.cs

示例3: ToDictionary

 /// <summary>
 /// Serialises the keys object as a media-storage-query-compatible, JSON-friendly data-structure.
 /// </summary>
 /// <returns>
 /// A JSON-friendly dictionary representation of the keys object in its current state.
 /// </returns>
 internal virtual System.Collections.Generic.IDictionary<string, object> ToDictionary()
 {
     System.Collections.Generic.IDictionary<string, object> dictionary = new System.Collections.Generic.Dictionary<string, object>();
     dictionary.Add("read", this.Read);
     dictionary.Add("write", this.Write);
     return dictionary;
 }
开发者ID:flan,项目名称:media-storage,代码行数:13,代码来源:Keys.cs

示例4: getLevelLinkedList

        public static System.Collections.Generic.Dictionary<System.Int16, System.Collections.Generic.List<BinaryTreeNode>> getLevelLinkedList(BinaryTreeNode head)
        {
            System.Collections.Generic.Dictionary<System.Int16, System.Collections.Generic.List<BinaryTreeNode>> result
                = new System.Collections.Generic.Dictionary<System.Int16, System.Collections.Generic.List<BinaryTreeNode>>();
            short level = 0;
            System.Collections.Generic.List<BinaryTreeNode> list = new System.Collections.Generic.List<BinaryTreeNode>();
            list.Add(head);
            result.Add(level, list);

            while (true)
            {
                System.Collections.Generic.List<BinaryTreeNode> list_loop = result[level];
                list = new System.Collections.Generic.List<BinaryTreeNode>();
                result.Add(++level, list);
                foreach (BinaryTreeNode btn in list_loop)
                {
                    if (btn.LeftNode != null)
                    {
                        list.Add(btn.LeftNode);
                    }
                    if (btn.RightNode != null)
                    {
                        list.Add(btn.RightNode);
                    }
                }
                if (list.Count == 0)
                {
                    break;
                }
            }
            return result;
        }
开发者ID:Sanqiang,项目名称:Algorithm-Win,代码行数:32,代码来源:CC4_4.cs

示例5: Start

 //Add attack's with their related game object here as below. The key is a string of the attack's name.
 void Start()
 {
     bounceOrbName = "blackOrbAttack";
     unblockAbleOrbName = "unblockableAttack";
     projectiles = new System.Collections.Generic.Dictionary<string, Rigidbody2D>();
     projectiles.Add(bounceOrbName, bounceOrb);
     projectiles.Add(unblockAbleOrbName, unblockableOrb);
 }
开发者ID:unit02,项目名称:SoftEng-306-Project-2,代码行数:9,代码来源:BossProjectileSpawner.cs

示例6: test656_int

		// Local output parameter s must not be initialized
		public void test656_int() 
		{
			var dict2 = new System.Collections.Generic.Dictionary<int, int>(); 
			dict2.Add(1, 100); 
			dict2.Add(2, 200); 
			int s;
			dict2.TryGetValue(2, out s); 
			AssertEquals(s, 200);
		}
开发者ID:Xtremrules,项目名称:dot42,代码行数:10,代码来源:Case656.cs

示例7: test657

        // Local output parameter s must not be initialized
        public void test657()
        {
			var dict2 = new System.Collections.Generic.Dictionary<NUMBER, string>(); 
			dict2.Add(NUMBER.ONE, "One"); 
			dict2.Add(NUMBER.TWO, "Two"); 
			string s = "-"; 
			dict2.TryGetValue(NUMBER.TWO, out s); 
			AssertEquals(s, "Two");
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:10,代码来源:Case657.cs

示例8: test656

		// Local output parameter s must not be initialized
		public void test656() 
		{
			var dict2 = new System.Collections.Generic.Dictionary<int, string>(); 
			dict2.Add(1, "One"); 
			dict2.Add(2, "Two"); 
			string s; // = "-"; 
			dict2.TryGetValue(2, out s); 
			AssertEquals(s, "Two");
		}
开发者ID:Xtremrules,项目名称:dot42,代码行数:10,代码来源:Case656.cs

示例9: ToRelative

        public string ToRelative(string DateString)
        {
            DateTime theDate = Convert.ToDateTime(DateString);
            System.Collections.Generic.Dictionary<long, string> thresholds = new System.Collections.Generic.Dictionary<long, string>();
            int minute = 60;
            int hour = 60 * minute;
            int day = 24 * hour;
            thresholds.Add(60, "{0} seconds ago");
            thresholds.Add(minute * 2, "a minute ago");
            thresholds.Add(45 * minute, "{0} minutes ago");
            thresholds.Add(120 * minute, "an hour ago");
            thresholds.Add(day, "{0} hours ago");
            thresholds.Add(day * 2, "yesterday");
            // thresholds.Add(day * 30, "{0} days ago");
            thresholds.Add(day * 365, "{0} days ago");
            thresholds.Add(long.MaxValue, "{0} years ago");

            long since = (DateTime.Now.Ticks - theDate.Ticks) / 10000000;
            foreach (long threshold in thresholds.Keys)
            {
                if (since < threshold)
                {
                    TimeSpan t = new TimeSpan((DateTime.Now.Ticks - theDate.Ticks));
                    return string.Format(thresholds[threshold], (t.Days > 365 ? t.Days / 365 : (t.Days > 0 ? t.Days : (t.Hours > 0 ? t.Hours : (t.Minutes > 0 ? t.Minutes : (t.Seconds > 0 ? t.Seconds : 0))))).ToString());
                }
            }
            return "";
        }
开发者ID:ArupAus,项目名称:issue-tracker,代码行数:28,代码来源:RelativeDate.cs

示例10: AnimationGlitchSpriteSingleton

        // CONSTRUCTOR ---------------------------------------------------------------------------------------
        public AnimationGlitchSpriteSingleton()
        {
            if(!isOkToCreate) Console.WriteLine (this + "is a singleton. Use get instance");
            if(isOkToCreate){
                FileStream fileStream = File.OpenRead("/Application/assets/animation/leftGlitch/leftOneLine.xml");
                StreamReader fileStreamReader = new StreamReader(fileStream);
                string xml = fileStreamReader.ReadToEnd();
                fileStreamReader.Close();
                fileStream.Close();
                XDocument doc = XDocument.Parse(xml);

                var lines = from sprite in doc.Root.Elements("sprite")
                    select new {
                        Name = sprite.Attribute("n").Value,
                        X1 = (int)sprite.Attribute ("x"),
                        Y1 = (int)sprite.Attribute ("y"),
              			Height = (int)sprite.Attribute ("h"),
              			Width = (int)sprite.Attribute("w"),
            };

               				_sprites = new Dictionary<string,Sce.PlayStation.HighLevel.GameEngine2D.Base.Vector2i>();
                foreach(var curLine in lines)
                {
                    _sprites.Add(curLine.Name,new Vector2i((curLine.X1/curLine.Width),(curLine.Y1/curLine.Height)));
                //note if you add more than one line of sprites you must do this
                // _sprites.Add(curLine.Name,new Vector2i((curLine.X1/curLine.Width),1-(curLine.Y1/curLine.Height)));
                //where 9 is the num of rows minus 1 to reverse the order :/
               			}
               				_texture = new Texture2D("/Application/assets/animation/leftGlitch/leftOneLine.png", false);
               				_textureInfo = new TextureInfo(_texture,new Vector2i(5,1));
            }
              		if(!isOkToCreate) {
                Console.WriteLine("this is a singleton. access via get Instance");
            }
        }
开发者ID:phoenixperry,项目名称:crystallography,代码行数:36,代码来源:AnimationGlitchSpriteSingleton.cs

示例11: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            CommandParameters cp = new CommandParameters();
            cp.CommandName = "MC_Workspace_AddControl";

            System.Collections.Generic.Dictionary<string, string> dic = new System.Collections.Generic.Dictionary<string, string>();
            dic.Add("ColumnId", "%columnId%");
            dic.Add("PageUid", "%pageUid%");

            cp.CommandArguments = dic;
            if (this.IsAdmin)
                this.OnClickCommandScript = CommandManager.GetCurrent(this.Page).AddCommand(string.Empty, string.Empty, "WorkspaceAdmin", cp);
            else
                this.OnClickCommandScript = CommandManager.GetCurrent(this.Page).AddCommand(string.Empty, string.Empty, "Workspace", cp);
            //clickDiv.Attributes.Add("onclick", this.OnClickCommandScript);
        }
开发者ID:0anion0,项目名称:IBN,代码行数:16,代码来源:AddTemplate.ascx.cs

示例12: saveInitialPositions

 private void saveInitialPositions()
 {
     initialPositions = new System.Collections.Generic.Dictionary<int, Vector3>();
     foreach(GameObject obj in GameObject.FindGameObjectsWithTag("respawn")) {
         initialPositions.Add(obj.GetInstanceID(), obj.rigidbody.position);
     }
 }
开发者ID:Janin-K,项目名称:SG,代码行数:7,代码来源:GameControl.cs

示例13: GetSystemData

        public string GetSystemData()
        {
            string str;
            UserInfo user;
            if (IsAuthenticated(out str) && GetUser(out user, ref str))
            {
                str += string.Format(", \"profile\": {{ \"userid\":{0}, \"displayname\":\"{1}\", \"image\":\"{2}\", \"IsSuperuser\":{3} }}, \"contacts\":[",
                    user.UserID, user.DisplayName, user.Image, user.IsSuperuser.ToString().ToLower());
                System.Collections.Generic.Dictionary<int, string> contacts = new System.Collections.Generic.Dictionary<int, string>();
                foreach (ContactInfo info in ContactInfo.GetContacts(user.UserID))
                {
                    UserInfo contactuser = UserInfo.Get(info.ContactID);
                    if (!contacts.ContainsKey(info.GroupID))
                        contacts.Add(info.GroupID, "{ \"groupid\": " + info.GroupID + ", \"groupname\": \"" + info.GroupName + "\", \"users\":[");
                    contacts[info.GroupID] += contactuser.ToJSON() + ",";
                }
                foreach (System.Collections.Generic.KeyValuePair<int, string> g in contacts)
                    str += g.Value.Remove(g.Value.Length - 1) + "] },";

                str = str.Remove(str.Length - 1) + "], \"topics\": [ ";
                foreach (TopicInfo info in TopicInfo.GetByUser(user.UserID))
                    str += string.Format("{{ \"id\":{0}, \"title\":\"{1}\" }},", info.TopicID, info.GetTitle());

                str = str.Remove(str.Length - 1) + "]";
            }
            return str;
        }
开发者ID:rosenkolev,项目名称:Communication-System,代码行数:27,代码来源:WebService.cs

示例14: TestCompression

        public void TestCompression()
        {
            System.Collections.Generic.Dictionary<string, string> dic = new System.Collections.Generic.Dictionary<string, string>();

            for (int i = 0; i < 10001; i++)
            {
                dic.Add(Guid.NewGuid().ToString(), Guid.NewGuid().ToString() + "::" + Properties.Settings.Default.Value_Text + "::" + Guid.NewGuid().ToString());
            }

            byte[] source_byte = Utility.Serialize(dic);
            byte[] dest_byte = Utility.Deflate(source_byte, System.IO.Compression.CompressionMode.Compress);


            byte[] dest_byte_2 = Utility.Deflate(dest_byte, System.IO.Compression.CompressionMode.Decompress);

            for (int i = 0; i < source_byte.Length; i++)
            {
                if (source_byte[i] != dest_byte_2[i])
                {
                    Microsoft.VisualStudio.TestTools.UnitTesting.Assert.Fail("Byte Array Error...");
                    break;
                }
            }

        }
开发者ID:rpannell,项目名称:Redis.Cache,代码行数:25,代码来源:UtilityTest.cs

示例15: CreateJobs

        private static System.Collections.Generic.Dictionary<IJobDetail, ISet<ITrigger>> CreateJobs(int[] intervals)
        {
            Log.Info("Building jobs");

            var jobDictionary = new System.Collections.Generic.Dictionary<IJobDetail, ISet<ITrigger>>();

            for (var index = 0; index < intervals.Length; index++)
            {
                var interval = intervals[index];
                Log.InfoFormat("Creating Job {0} with interval {1}...", index, interval);

                var job =
                    JobBuilder.Create<SendMessageJob>()
                        .WithIdentity("sendMessageJob" + index)
                        .UsingJobData("message", $"Job {index} with interval {interval} from process {Process.GetCurrentProcess().Id}")
                        .Build();

                var trigger =
                    TriggerBuilder.Create()
                        .WithIdentity("trigger" + index)
                        .StartNow()
                        .WithSimpleSchedule(x => x.WithIntervalInSeconds(interval).RepeatForever())
                        .Build();

                var set = new HashSet<ITrigger> { trigger };

                jobDictionary.Add(job, set);
            }

            return jobDictionary;
        }
开发者ID:VictorGavrish,项目名称:MentoringD2D3,代码行数:31,代码来源:Program.cs


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