我感觉很困惑的方式或者C#的foreach
和Java的的增强的作品,甚至更令人沮丧的是明白为什么我还没有碰到过这个细节来之前.
但无论如何,事实上,我真的很想理解为什么这个看似相似的流控制语句的工作方式如此不同.为了便于说明,我们假设我们需要迭代一个整数数组,两个实现都是这样的:
C#4.0(代码)
class Program
{
public static void Main(string[] args)
{
int[] foobar = new int[] {0, 1, 1, 2, 3, 5, 8, 13, 21};
Console.WriteLine(String.Format("[DEBUG] type: {0}", foobar.GetType()));
Console.WriteLine(String.Format("[DEBUG] length: {0}", foobar.Length));
try
{
for (int i = 0; i < foobar.Length; i++)
{
Console.Write(String.Format("{0} ", foobar[i]));
}
Console.Write(Environment.NewLine);
foreach (var i in foobar) {
Console.Write(String.Format("{0} ", foobar[i]));
}
}
catch (Exception exception)
{
Console.Write(Environment.NewLine);
Console.WriteLine(exception.ToString());
}
finally
{
Console.Write(Environment.NewLine); …
Run Code Online (Sandbox Code Playgroud) 我有一张桌子,只有一列由5种颜色组成 -
colour
-------
red
black
white
green
orange
Run Code Online (Sandbox Code Playgroud)
我希望得到所有的组合
(红色,橙色)(黑色,白色)...等等除了相同的那些.我试图与自己交叉加入表.
select *
from table1 cross join table1
Run Code Online (Sandbox Code Playgroud)
但我没有得到所需的答案.它返回了所有的组合.也是相同的那些.我能得到它吗?有没有其他方法可以做到这一点而不创建另一个表???
我需要在页面加载后在10秒内显示div(例如#mybox),让它在另外10秒内保持可见,然后用漂亮的滑入/滑出效果隐藏.
非常感谢任何提示/帮助!
嗨,我正在尝试格式化我的Url,以使其看起来更加用户友好.到目前为止,我设法用" - "替换空格,但似乎有特殊的字符,如#和:显示为编码数据.这是什么我的意思是:
http://localhost:51208/Home/Details/C%23-in-Depth%2c-Second-Edition/BookId-3
Run Code Online (Sandbox Code Playgroud)
"#"符号显示为%23,","显示为%2c.我希望能够用原始符号替换此编码.
这样的方式存在吗?
我有两个数组,
Array 1(
'A' => string '13' (length=2)
'B' => string '13' (length=2)
)
Array 2(
9 => string '13' (length=2)
)
Run Code Online (Sandbox Code Playgroud)
但是,当我用它array_merge
来组合这些时arrays
,它就像这样向我展示
Array(
'A' => string '13' (length=2)
'B' => string '13' (length=2)
0 => string '13' (length=2)
)
Run Code Online (Sandbox Code Playgroud)
每当有数值时,array_merge
它会自动递增,而不是原始值.
插入线我有一个错误,就是这个坏男孩
mysql_query("INSERT INTO accounts('username', 'password', 'firstname', 'lastname', 'email')
VALUES($username, $password, $firstname, $lastname, $email)")
or die("Could not create account! <br/>" . mysql_error());
Run Code Online (Sandbox Code Playgroud)
我提供的错误如下:
无法创建帐户!
您的SQL语法有错误; 查看与您的MySQL服务器版本相对应的手册,以便在''username','password','firstname','lastname','email'附近使用正确的语法.)VALUES(test,test,'在第1行
我怀疑它与未被正确调用的变量有关?
c# ×2
php ×2
arrays ×1
asp.net-mvc ×1
combinations ×1
cross-join ×1
html ×1
insert ×1
java ×1
javascript ×1
jquery ×1
mysql ×1
permutation ×1
sql ×1