小编Mic*_*ray的帖子

仅反序列化 JSON 响应的单个节点

我有一个 json 响应,例如

{
  "appStatus":{
    "status":true
  },
  "lastSyncDate":"06-07-2013 13.54.27",
  "configResponse":{
    "status":{
      "status":true
    },
    "configs":{
      "APPLOGENABLED":{
        "configCode":"APPLOGENABLED",
        "configDesc":"enable or disable logging from front end",
        "configType":"TAB",
        "configValue":"Y"
      },
      "COMMENTSTIMER":{
        "configCode":"COMMENTSTIMER",
        "configDesc":"timer for comments in seconds",
        "configType":"TAB",
        "configValue":"60"
      },
      "SUMMARYTIMER":{
        "configCode":"SUMMARYTIMER",
        "configDesc":"timer for summary in seconds",
        "configType":"TAB",
        "configValue":"30"
      },
      "ALERTSTIMER":{
        "configCode":"ALERTSTIMER",
        "configDesc":"timer for alerts in seconds",
        "configType":"TAB",
        "configValue":"60"
      }
    },
    "lastSyncDate":"06/07/2013 13.48.13"
  }
}
Run Code Online (Sandbox Code Playgroud)

使用 json.NET,我想提取configResponse到字典中。我知道我可以像这样直接转换 Dictionary 对象

  JsonConvert.DeserializeObject<Dictionary<string,string>>().... 
Run Code Online (Sandbox Code Playgroud)

但由于configResponse是一个子元素,我无法根据需要解析它。

我想将上面的 json 响应反序列化为

public class ConfigResponse
{
    public Status …
Run Code Online (Sandbox Code Playgroud)

.net c# json dictionary json.net

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

c#中的奇怪减法

我正在做ac#program ..我必须做一个简单的数学运算.

72057594037927936.0 - 255.0 = .....
Run Code Online (Sandbox Code Playgroud)

这两个数字都是双倍的...我得到了

72057594037927680.0 
Run Code Online (Sandbox Code Playgroud)

代替

72057594037927681.0 
Run Code Online (Sandbox Code Playgroud)

请问有人可以解释一下,怎么可能?

感谢名单

c# math

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

不修改循环中的列表但修改了抛出错误集合; 枚举操作可能无法执行

我在c#中使用以下代码,如下所示.

var result = (from o in db.tblOrderMasters
              join od in db.tblOrderDetails on o.order_id equals od.orderdetails_orderId
              join c in db.tblCountryMasters on o.order_dCountry equals c.country_id
              join cu in db.tblCustomers on o.order_Custid equals cu.cust_id
              where o.order_id == orderid && o.order_active == true && o.order_IsDeleted == false && (o.order_status == 2)
              select new
              {
                 Code = o.order_code,
                 Name = o.order_dFirstName + " " + o.order_dLastName,
                 Quantity = od.Quantity,
                 [...snip...]
              }).ToList();

var Qresult =  result;
try
{
    foreach (var r in result)
    {
         if …
Run Code Online (Sandbox Code Playgroud)

c# generics

0
推荐指数
1
解决办法
131
查看次数

初学c#麻烦

我是c#的新手,我有一点问题.我想制作一个简单的程序来询问用户1-50之间的整数,然后在控制台上显示是否为奇数.所以,我试过的是这样的:

 Console.WriteLine("Skriv ut ett heltal: ");
 int x = int.Parse(Console.ReadLine());

 if (x == 1,3,5,7,9,11,13,15,17,19)
 {
     Console.WriteLine("The number is odd");
 }
 else 
 {
     Console.WriteLine("The number is not odd");
 }
Run Code Online (Sandbox Code Playgroud)

现在我在if语句中遇到错误.我怎样才能解决这个问题?

c#

-1
推荐指数
1
解决办法
230
查看次数

c#减法即使是小数也不准确?

我正在学习TDD,并决定创建一个Calculator类来开始.我先做了基本的,现在我正在使用Square Root功能.

我正在使用这种方法来获取根http://www.math.com/school/subject1/lessons/S1U1L9DP.html 我用少量数字测试它,我总能得到准确的答案.很容易理解.

现在我有一个奇怪的问题,因为有了一些数字,我得到了正确的答案,而有些,我没有.

我调试了代码,发现当我使用减法时,我得不到正确的答案.

我正在使用小数来获得最准确的结果.

当我做:

18 / 4.25
Run Code Online (Sandbox Code Playgroud)

我目前正在: 4.2352941176470588235294117647

什么时候应该:( 4.2352941176470588235294117647059使用Windows计算器)

在路的尽头,这是我最接近根的18:

4.2426406871192851464050688705 ^ 2 = 18.000000000000000000000022892
Run Code Online (Sandbox Code Playgroud)

我的问题是:

我可以更精确吗?

c# math

-4
推荐指数
1
解决办法
1312
查看次数

标签 统计

c# ×5

math ×2

.net ×1

dictionary ×1

generics ×1

json ×1

json.net ×1