程序设计

专业和发烧友程序员的问答








28
何时使用struct?
什么时候应该在C#中使用struct而不是class?我的概念模型是当项目仅仅是值类型的集合时使用结构。一种逻辑上将它们组合在一起的方法。 我在这里遇到了这些规则: 结构应代表单个值。 结构的内存占用量应少于16个字节。 创建后不应更改结构。 这些规则有效吗?结构在语义上是什么意思?
1390 c#  struct 

12
在Bash中循环浏览文件内容
我如何遍历文本文件的每一行 Bash? 使用此脚本: echo "Start!" for p in (peptides.txt) do echo "${p}" done 我在屏幕上得到以下输出: Start! ./runPep.sh: line 3: syntax error near unexpected token `(' ./runPep.sh: line 3: `for p in (peptides.txt)' (后来我想做些更复杂的事情 $p不只是输出到屏幕上。) 环境变量SHELL是(来自env): SHELL=/bin/bash /bin/bash --version 输出: GNU bash, version 3.1.17(1)-release (x86_64-suse-linux-gnu) Copyright (C) 2005 Free Software Foundation, Inc. …
1387 linux  bash  loops  unix  io 

17
静态只读与常量
我已阅读有关const和static readonly领域。我们有一些仅包含常量值的类。用于我们系统中的各种事物。所以我想知道我的观察是否正确: 这些常量值是否应该始终static readonly适用于所有公开的东西?并且仅const用于内部/受保护/私有值吗? 您有什么推荐的吗?我是否应该甚至不使用static readonly字段,而应该使用属性?
1386 c#  constants 

30
漂亮的git分支图
我看过一些书籍和文章中有一些非常漂亮的git分支和提交图。如何制作git历史记录的高质量可打印图像?
1385 git  git-log 





By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.