下面是C#中的别名列表(C#中字符串和字符串的区别是什么?):
object: System.Object
string: System.String
bool: System.Boolean
byte: System.Byte
sbyte: System.SByte
short: System.Int16
ushort: System.UInt16
int: System.Int32
uint: System.UInt32
long: System.Int64
ulong: System.UInt64
float: System.Single
double: System.Double
decimal: System.Decimal
char: System.Char
Run Code Online (Sandbox Code Playgroud)
我可以看到bool通过char为小写的别名,因为它们是原始类型.
为什么对象和字符串没有大写,因为它们是复杂的类型?这是开发人员的疏忽,还是他们必须小写的必要原因?或者这是一个自以为是的问题?
你最终得到的东西string.Format()不是String.Format(),而是看起来很时髦,让我认为string是一个变量.
如何检查单元格 #0 中的值是否等于单元格 #1 中的值?我正在尝试编写相当于以下内容的代码:
if(a == b)
{
//do stuff
}
else
{
//do something else
}
Run Code Online (Sandbox Code Playgroud)
我读过Brainfuck 比较 2 个数字大于或小于,第二个答案让我大致了解了我需要做什么,但我无法弄清楚。(该解决方案给出if a < b, else。)
我想我需要做一些事情来减少这两个值,如果它们同时达到 0,那么它们就是真的。但每次我想到这个问题时,我总是被困在同一个出口点。
如何检查 Brainfuck 中两个细胞是否相等?
我正在尝试创建一个高X像素,Y像素短的.png图像.我没有找到我在dlang.org上寻找的东西,并且很难通过谷歌找到任何其他资源.
您能否提供一个如何在D中创建.png图像的示例?
例如,BufferedImage off_Image = new BufferedImage(100, 50, BufferedImage.TYPE_INT_ARGB);来自http://docs.oracle.com/javase/tutorial/2d/images/drawonimage.html是我正在寻找的(我认为),除了D编程语言.
我在Linux Mint 16上使用PhpStorm.我创建了一个Hello World,但我正在努力运行它.我收到错误"未安装PHP解释器.按'修复'编辑项目配置."

当我点击"修复"时,我得到:

任何想法如何解决这一问题?没有解释器选项.
您可以隐式地将int转换为double: double x = 5;
您可以显式地将int转换为double: double x = (double) 5;
您可以显式地将double转换为int: int x = (int) 5.0;
为什么不能隐式地将double转换为int?: int x = 5.0;
我试图使用Console :: SetCursorPosition(int,int)方法.当我添加该行时using namespace System;,如前面的MSDN文档中的C++示例所示,我收到错误"Error: name must be a namespace name".我现在已经尝试了几个小时,但令人沮丧但没有成功.我已经看到了大量的Visual Studio 2010和2012的文档,但2013年的文档很少.我最接近的是Lib Files作为链接器输入.步骤1-3很简单,但我不清楚第4步:"修改附加依赖属性.".看看已经存在的内容,似乎我只能添加一个.lib文件.但是我没有System.lib.
如此沮丧,如此困惑.
如何在Visual Studio 2013 Update 4 for C++中使用System命名空间?
我不明白什么>> =意味着(我认为大于或等于> =)也是:(时间和1)从下面.
function repeat (string, times) {
var result = ''
while (times > 0) {
if (times & 1) result += string
times >>= 1
string += string
}
return result
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个bool数组的数组.我希望除了具有bool数组的每个组合{false, false, false, false}.我希望这个数组的顺序保持它的子数组,使它以最小的数量顺序上升到大多数真实状态.(向后订单很好,但仍然必须订购.)
阵列的每个子集使得它们具有相同数量的trues应该是随机顺序的.
我可以这样硬编码:
private bool[][] GetBoolArrays()
{
var fourDoorList = new List<bool[]>();
fourDoorList.Add(new bool[4] { true, true, true, true });
fourDoorList = fourDoorList.OrderBy(c => Random.Range(float.MinValue, float.MaxValue)).ToList();
var threeDoorList = new List<bool[]>();
threeDoorList.Add(new bool[4] { true, true, true, false });
threeDoorList.Add(new bool[4] { true, true, false, true });
threeDoorList.Add(new bool[4] { true, false, true, true });
threeDoorList.Add(new bool[4] { false, true, true, true });
threeDoorList = threeDoorList.OrderBy(c => Random.Range(float.MinValue, float.MaxValue)).ToList();
var twoDoorList = new List<bool[]>();
twoDoorList.Add(new …Run Code Online (Sandbox Code Playgroud) 我的字典声明如下:
private static Dictionary<string, Dictionary<string, string>> myDictionary;
Run Code Online (Sandbox Code Playgroud)
我想全局初始化它.我最接近的是初始化外部词典,但仍然留下了对内部词典的空引用:
private static Dictionary<string, Dictionary<string, string>> myDictionary
= new Dictionary<string, Dictionary<string, string>>();
Run Code Online (Sandbox Code Playgroud)
我需要避免在方法中初始化它,因为我不想强迫用户在能够使用我的类之前调用方法.用户只能访问静态方法.我可以在调用其中一个方法时创建一个单例,但那很脏.
如何在全球范围内声明这两个词典?其中一个的东西(虽然都没有编译):
private static Dictionary<string, Dictionary<string, string>> myDictionary
= new Dictionary<string, new Dictionary<string, string>>();
Run Code Online (Sandbox Code Playgroud)
要么
private static Dictionary<string, string> inner = new Dictionary<string, string>();
private static Dictionary<string, Dictionary<string, string>> myDictionary
= new Dictionary<string, inner>();
Run Code Online (Sandbox Code Playgroud) 我有一个子类,它覆盖了基类中的方法.基类的方法有默认参数.我的子类需要在重写的方法中显示这些默认参数,尽管它们不需要是可选的.
public class BaseClass
{
protected virtual void MyMethod(int parameter = 1)
{
Console.WriteLine(parameter);
}
}
public class SubClass : BaseClass
{
//Compiler error on MyMethod, saying that no suitable method is found to override
protected override void MyMethod()
{
base.MyMethod();
}
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我将方法签名更改为
protected override void MyMethod(int parameter = 1)
Run Code Online (Sandbox Code Playgroud)
甚至
protected override void MyMethod(int parameter)
Run Code Online (Sandbox Code Playgroud)
那很开心 我希望它接受无参数方法签名,然后在base.MyMethod()调用时允许它使用默认参数.
为什么子类的方法需要参数?
c# inheritance overriding compiler-errors default-parameters
c# ×5
alias ×1
arrays ×1
boolean ×1
brainfuck ×1
c++ ×1
casting ×1
combinations ×1
complextype ×1
d ×1
dictionary ×1
equality ×1
if-statement ×1
image ×1
inheritance ×1
interpreter ×1
java ×1
javascript ×1
linux ×1
namespaces ×1
naming ×1
overriding ×1
php ×1
phpstorm ×1
static ×1
unity5 ×1
using ×1