我有这行代码
var count = materials.Where(i => i.MaterialType1 == MaterialType.Major).Count();
Run Code Online (Sandbox Code Playgroud)
Resharper促使我改为
var count = materials.Count(i => i.MateriakType1 == MaterialType.Major);
Run Code Online (Sandbox Code Playgroud)
为什么?任何人都可以告诉我改变的好处是什么?
我们在应用程序中使用Telerik RadNumericUpDown控件(2013版)来显示和编辑double值和整数; 该控件适用于可以为空的double类型:它不显示空值,0.00显示0值.我们希望整数具有相同的行为,但控件始终显示0表示空值.我已经尝试将NullValue设置为空字符串&null,基于此处的讨论:http://www.telerik.com/community/forums/silverlight/numericupdown/null.aspx,但这不能解决我们的问题.
XAML:
<telerik:RadNumericUpDown Value="{Binding Path=Contents, Mode=TwoWay}"
NumberDecimalDigits="0"
IsEnabled="True"
IsEditable="True"
IsInteger="True"
NullValue=""
MinWidth="70"
HorizontalAlignment="Left"
HorizontalContentAlignment="Left" />
Run Code Online (Sandbox Code Playgroud)
Contents属性是一个可以为null的int.
任何帮助表示赞赏.
如何将此转换为使用Linq到数据集?
foreach (Row row in Rows)
{
if (row.material> 0)
sumtid += row.time * row.material;
else
sumtid += row.time;
}
Run Code Online (Sandbox Code Playgroud) 我有以下用例:
Account Name | Ref 1 | Ref 2
Account1 | Mike | John
Account1 | |
Account1 | |
Account2 | Carl | Mike
Account2 | Carl | Mike
Run Code Online (Sandbox Code Playgroud)
具有相同AccountName,Ref1,Ref2的行应该合并在一起,但是
如果包含空Ref1或Ref2不应合并.
结果应该是:
Account Name | Ref 1 | Ref 2
Account1 | Mike | John
Account1 | |
Account1 | |
Account2 | Carl | Mike
Run Code Online (Sandbox Code Playgroud)
AccountViewModel具有属性:AccountName,Ref1,Ref2
.
var result = new List<AccountViewModel >();
source.GroupBy(vm => new { vm.AccountName, vm.Ref1, vm.Ref2})
.Select(group =>
{
if (group.All(vm => string.IsNullOrWhiteSpace(vm.Ref1)) || …
Run Code Online (Sandbox Code Playgroud) 我最近读到HTML 5附带了一种嵌入音频文件的标准方法.我需要使用此功能,但我不知道哪些是受支持的文件.
<audio controls>
<source src="track.mp3" type="audio/mpeg">
</audio>
Run Code Online (Sandbox Code Playgroud)
只有mpeg?
谢谢