static void Main(string[] args)
{
List<int> li = new List<int>() { 1, 20, 30, 4, 5 };
GetNosLessThan5(li);
}
public static IEnumerable<int> GetNosLessThan5(List<int> numbers)
{
foreach (var v in numbers)
{
if (v < 5)
yield return v;
}
}
Run Code Online (Sandbox Code Playgroud)
我在void main的开头放了一个调试点.当我连续按f11时,黄色箭头仅覆盖主功能块,调试终止.它根本没有达到"getnoslessthan5"的功能.融合.!
int check_authentication(char *password)
// 1
{
int auth_flag = 0;
char password_buffer[16];
strcpy(password_buffer, password); // 2
if(strcmp(password_buffer, "brillig") == 0)
auth_flag = 1;
if(strcmp(password_buffer, "outgrabe") == 0)
auth_flag = 1;
return auth_flag;
}
check_authentication(argv[1]) // Passing a 'Command Line argument'
// ( which is a string in this example) to the check_authentication function.
Run Code Online (Sandbox Code Playgroud)
我有两个问题.上面标有1和2的行,
该函数需要一个字符指针作为参数.但是我们传递一个"字符串"i,一个字符数组作为参数.怎么样 ?????
指针"password"(指向一个字符)所保存的地址被复制到"password_buffer"数组中.对我来说完全是无稽之谈 .请解释一下.