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


C# Dictionary.ToQueryString方法代码示例

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


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

示例1: ToQueryString

 public void ToQueryString()
 {
     Dictionary<string, string> Collection = new Dictionary<string, string>();
     Collection.Add("A", "1");
     Collection.Add("B", "2");
     Assert.Equal("?A=1&B=2", Collection.ToQueryString());
 }
开发者ID:gwilkinson,项目名称:Craig-s-Utility-Library,代码行数:7,代码来源:DictionaryExtensions.cs

示例2: GetParametersString

        public string GetParametersString()
        {
            var nvc = new Dictionary<string, string>();

            var properties = GetType().GetProperties();

            foreach (var prop in properties)
            {
                var propValue = prop.GetValue(this);

                if (propValue is IEnumerable && !(propValue is string))
                {
                    if ((propValue as ICollection).Count > 0)
                    {
                        var multiValuesProperty = new StringBuilder();
                        foreach (var value in propValue as IEnumerable)
                        {
                            var trimedVaule = value.ToString().Replace(" ", "");
                            multiValuesProperty.Append(trimedVaule);
                            multiValuesProperty.Append("|");
                        }
                        multiValuesProperty.Remove(multiValuesProperty.Length - 1, 1);

                        nvc.Add(prop.Name, multiValuesProperty.ToString());
                    }
                }
                else if (propValue != null)
                    nvc.Add(prop.Name, propValue.ToString());
            }
            return nvc.ToQueryString();
        }
开发者ID:ChenKKaminsky,项目名称:Route-Planner,代码行数:31,代码来源:GoogleMapsParameters.cs


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