简体   繁体   English

C# 使用 < >(不是大于/小于)

[英]C# use of < > (not as greater than / less than)

In C# Sometimes the use of < and > is required在 C# 中有时需要使用 < 和 >

Lists is one such example列表就是这样一个例子

List mine = new List(); List mine = new List();

in this case why are the <> needed when declaring the type?在这种情况下,为什么在声明类型时需要 <>?

Variables and arrays do not require this so why are lists different?变量和数组不需要这个,为什么列表不同?

Yes, you can use the break keyword.是的,您可以使用 break 关键字。

See:看:

http://www.php.net/manual/en/control-structures.break.php http://www.php.net/manual/en/control-structures.break.php

Instead of using the big red emergency break button, rather exit the loop gracefully and provide your fellow programmer with a boolean up on top to let him know that there's an additional condition that might end the loop.与其使用红色的大紧急中断按钮,不如优雅地退出循环,并在顶部为您的程序员同事提供一个布尔值,让他知道有一个额外的条件可能会结束循环。

<?php
$i          = 0;
$stillGoing = true;

while ($i < 5 && $stillGoing) {
    echo $i;

    if ($i == 3) {
        //break out of loop
        $stillGoing = false;
    }
    $i = $i++;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM