小编Chi*_*tan的帖子

如何将类转换为Dictionary <string,string>?

现在我再次解释我对词典的热切期待!从我上一个问题的回答中,这个问题在我脑海中浮现!

现在实际的一点是我可以将类转换为字典吗?

在Dictionary中,我希望我的类属性为KEY,特殊属性的值为VALUE

假设我的班级是

public class Location
{
    public string city { get; set; }
    public string state { get; set; }
    public string country { get; set;
}
Run Code Online (Sandbox Code Playgroud)

现在假设我的数据是

city = Delhi
state = Delhi
country = India
Run Code Online (Sandbox Code Playgroud)

现在你可以轻松理解我的观点!

我想制作字典!那本字典应该是这样的

Dictionary<string,string> dix = new Dictionary<string,string> ();
dix.add("property_name", "property_value");
Run Code Online (Sandbox Code Playgroud)

我可以获得价值!但是我怎样才能得到属性名称(而不是价值)?

我应该编码什么来创建它动态!这应该适用于我想要的每一堂课?

你可以理解这个问题

我怎样才能从特定类中获取属性列表?

c# asp.net dictionary

60
推荐指数
3
解决办法
5万
查看次数

如何删除asp.net中的特定会话?

我正面临一个问题.我创建了两个会话:

  1. Session["userid"] = UserTbl.userid;
  2. Session["userType"] = UserTbl.type;

我知道如何使用删除会话Session.clear().我想删除会话"userType".

如何删除特定会话?

c# asp.net session

37
推荐指数
4
解决办法
12万
查看次数

无法连接远程服务器(Web服务)

在此输入图像描述

我试图将这个Web服务集成到我的asp.net项目中,但它会弹出这种类型的错误!如果您对此有任何想法,请给我解决方案.有很多关于oodle web服务和oodle API的材料.

试试这个网址,了解我的问题 http://api.oodle.com/api/v2/listings?key=TEST®ion=chicago&category=vehicle/car

c# asp.net rest webservices-client

6
推荐指数
1
解决办法
2万
查看次数

这可能在JSON中吗?

我目前正在使用json.net!我知道如何反序列化json数据以及如何映射我们的类.现在我渴望一些疑问!

假设我的jsonstrings是

"attributes":{
            "color":"Brown",
            "condition":"Used",
            "currency":"USD",
            "price":"10500",
            "price_display":"$10,500",
         }
Run Code Online (Sandbox Code Playgroud)

和我的属性类(我想在其上反序列化字符串)是

Public class Attribute
{
        public string name{ get; set; }
        public string value{ get; set; }
}
Run Code Online (Sandbox Code Playgroud)

现在我使用以下代码进行反序列化.

 JavaScriptSerializer ser = new JavaScriptSerializer();
 <classname> p = ser.Deserialize<classname>(jsonString);
Run Code Online (Sandbox Code Playgroud)

显然,这段代码根本不适用于上面的jsonstring.

现在如何在一个类中绑定这些名称值对?这可能吗 ?

将来,属性可能超过10但格式将与名称值对相同

c# asp.net json.net deserialization

6
推荐指数
1
解决办法
313
查看次数

为什么我应该在JSON反序列化中使用List <>而不是数组?

首先让我告诉你一件事,我发布这个问题只是为了渴望和增加我的知识.希望你能清除我的疑惑!

现在让我们来谈谈

我从之前的问题答案中得到了这个问题

实际上问题是如果我使用

List<oodleListings> listings;
Run Code Online (Sandbox Code Playgroud)

代替

oodleListings[] listings;
Run Code Online (Sandbox Code Playgroud)

它工作正常!! 我可以轻松地反序列化我的json字符串.

现在的问题是为什么在反序列化json时不支持数组?

使用的实际原因Listarray什么?

c# arrays json list deserialization

6
推荐指数
1
解决办法
2524
查看次数

如何修改web.config部分运行时?

我创建了一个直接映射到ConfigSectionweb的类.配置.我的课程定义如下:

public class myConfiguration: ConfigurationSection
{
    public myConfiguration()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    [ConfigurationProperty("fileName", IsRequired = true)]
    public string FileName
    {
        get { return this["fileName"] as string; }
    }


    [ConfigurationProperty("rootNode", IsRequired = true)]
    public string RootNode
    {
        get { return this["rootNode"] as string; }
    }

    [ConfigurationProperty("childNode", IsRequired = true)]
    public string ChildNode
    {
        get { return this["childNode"] as string; }
    }

    [ConfigurationProperty("comparableAttributes", IsRequired = true)]
    public string ComparableAttributes
    {
        get
        { return this["comparableAttributes"] …
Run Code Online (Sandbox Code Playgroud)

c# xml asp.net

5
推荐指数
1
解决办法
3549
查看次数

从JSON获取数据时出现混乱

我正在尝试使用一个以json格式返回所需数据的Web服务.现在我的实际观点是我可以从字符串中的特定Web服务URL获取数据.

  string url= @"http://api.oodle.com/api/v2/listings?key=TEST&region=chicago&category=vehicle&format=json";

  string jsonString = new WebClient().DownloadString(url);
Run Code Online (Sandbox Code Playgroud)

现在重点是我以字符串形式获取数据(采用JSON格式).但我不知道如何将字符串转换为JSON字符串以及如何从此字符串中获取数据.

让我举个例子让你轻松理解

如果我的jsonString是这样的

{
   "current":{
      "region":{
         "id":"chicago",
         "name":"Chicago"
      },
      "category":{
         "id":"vehicle",
         "name":"Cars & Vehicles",
         "abbrev":"Vehicles"
      },
      "start":1,
      "num":10
   }
}
Run Code Online (Sandbox Code Playgroud)

如何从该字符串中获取region_name?希望你能理解我 !尝试使用Test Link!

c# asp.net json

5
推荐指数
1
解决办法
1118
查看次数

混淆我的Xpath表达式应该是什么?

我的categories.xml文件如下所示

<categories>
  <root name="Cars -Vehicles" id="CV"></root>
  <root name="Personals" id="PER"></root>
  <root name="Real Estate" id="RE"></root>
  <root name="Property For Rent" id="PFR"></root>
  <root name="Community" id="COM"></root>
</categories>
Run Code Online (Sandbox Code Playgroud)

和我的attibutes.xml文件如下

<attributes>

  <attribute value="ethnicity=ethnicity_african_american" name ="American Indian" categoryid="PER"/>
  <attribute value="ethnicity=ethnicity_asian_pacific_islander" name ="Asian - Pacific Islander" categoryid="PER"/>
  <attribute value="ethnicity=ethnicity_caucasian" name ="Caucasian" categoryid="PER"/>


  <attribute value="amenities=amenities_ac" name ="AC" categoryid="RE, PFR"/>
  <attribute value="amenities=amenities_alarm" name ="Alarm" categoryid="RE, PFR"/>

</attributes>
Run Code Online (Sandbox Code Playgroud)

我限制了我attributeDropdown的选择categoriesDropDown.代码如下

 protected void ddCategories_SelectedIndexChanged(object sender, EventArgs e)
 {
            XmlDataSource xd = new XmlDataSource();
            xd.DataFile = Server.MapPath("Xmls") + "\\attributes.xml";
            xd.XPath = …
Run Code Online (Sandbox Code Playgroud)

.net c# xml asp.net xpath

5
推荐指数
1
解决办法
143
查看次数

如何在asp.net中获取客户端机器的临时路径?

我使用Path.Gettemppath()来获取临时路径.但它返回服务器的临时路径.我想将一些数据客户端存储在客户端的临时文件夹中.我怎样才能获得临时路径?

c# asp.net

3
推荐指数
1
解决办法
2282
查看次数