小编Meh*_*ani的帖子

在C#中比较字符串和对象

看到这段代码:

object x = "mehdi emrani";
string y = "mehdi emrani";
Console.WriteLine(y == x);
Run Code Online (Sandbox Code Playgroud)

返回true.

但是这段代码:

object x = "mehdi emrani";
string y = "mehdi ";
y += "emrani";
Console.WriteLine(y == x);
Run Code Online (Sandbox Code Playgroud)

回报false.

因此,当我在第一个代码中比较String和Object时,我得到了true.
但是当我在第二个代码中比较它时,我得到了false.

两个字符串都相同,但为什么当我追加到字符串时,我的结果会返回false

.net c# string

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

如何在LINQ投影中仅修改一个或两个字段?

我有这个LINQ查询:

List<Customers> customers = customerManager.GetCustomers();

return customers.Select(i => new Customer {
    FullName = i.FullName,
    Birthday = i.Birthday, 
    Score = i.Score,
    // Here, I've got more fields to fill
    IsVip = DetermineVip(i.Score)
}).ToList();
Run Code Online (Sandbox Code Playgroud)

换句话说,我只想在我的业务方法中根据条件修改客户列表中的一个或两个字段.我有两种方法可以做到这一点,

  1. 使用for...each循环,循环客户并修改该字段(命令式方法)
  2. 使用LINQ投影(声明方法)

在LINQ查询中是否有任何技术可用于仅修改投影中的一个属性?例如,类似于:

return customers.Select(i => new Customer {
    result = i // telling LINQ to fill other properties as it is
    IsVip = DetermineVip(i.Score) // then modifying this one property
}).ToList();
Run Code Online (Sandbox Code Playgroud)

c# linq projection

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

将HTML页面划分为水平部分,没有垂直滚动条

我正在尝试创建这样的东西:

http://jsfiddle.net/S6FUQ/

HTML是:

<div id="container">
    <header></header>
    <main>
        <section class="half"></section>
        <section class="half"></section>
    </main>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS是:

* {
    margin: 0; padding: 0;
}
html, body, #container {
    height: 100%;
}
header {
    height: 50px;
    background: gray;
}
main {
    height: 100%;
    background: green;
}
.half {
    height: 50%;
}
.half:first-child {
    background: blue;
}
.half:last-child {
    background: yellow;
}
Run Code Online (Sandbox Code Playgroud)

在其中,我在顶部有一条细带,我想将屏幕的其余部分分成两个相等的部分,但我不希望出现垂直滚动条.

我试过margin-bottom: 50px;main,但它没有用.我该怎么办?

html css layout css3

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

有没有办法在JSON中更改日期时间格式?

我正在使用JSON将数据发送到客户端.但是,日期字段会转换为时间跨度格式/Date(1363807800000)/.

反正有没有摆脱它,让服务器发送客户端的DateTime2013/7/21 3:44 PM

javascript c# datetime json

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

为什么jQuery的"on"比"live"更好

我发现现在有更多的开发人员正在使用$('#element-id').on()方法而不是$('#element-id').live()方法.

为什么?这种live方法没有什么?

jquery

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

标签 统计

c# ×3

.net ×1

css ×1

css3 ×1

datetime ×1

html ×1

javascript ×1

jquery ×1

json ×1

layout ×1

linq ×1

projection ×1

string ×1