范围问题: [英] scope question :

查看:59
本文介绍了范围问题:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

for(int i = 0; i< 6; i ++)

{

//

}


在for循环后我不会超出范围......?

for(int i=0;i<6;i++)
{
//
}

wont i go out of scope after the for loop ...?

推荐答案

是的。

" NotYetaNurd" <否********* @ Matrix.com>在消息中写道

news:ec ************** @ TK2MSFTNGP10.phx.gbl ...
Yep.

"NotYetaNurd" <No*********@Matrix.com> wrote in message
news:ec**************@TK2MSFTNGP10.phx.gbl...
for(int i = 0; i< 6; i ++)
{
//
}

在for循环后我不会超出范围......?
for(int i=0;i<6;i++)
{
//
}

wont i go out of scope after the for loop ...?



是的,你去......那只是你在范围内定义的东西
for循环的
br />

Nirosh。


" NotYetaNurd" <否********* @ Matrix.com>在消息中写道

news:ec ************** @ TK2MSFTNGP10.phx.gbl ...
yes you go ... that is only from the things you have define within the scope
of the for loop

Nirosh.

"NotYetaNurd" <No*********@Matrix.com> wrote in message
news:ec**************@TK2MSFTNGP10.phx.gbl...
for(int i = 0; i< 6; i ++)
{
//
}

在for循环后我不会超出范围......?
for(int i=0;i<6;i++)
{
//
}

wont i go out of scope after the for loop ...?



当我尝试这个

for(int i = 0; i< 6; i ++)

{

for(int j = 0; j< someConst; j ++)

{

}

}


int i = 1;

foreach(.......)

{

asdf = - i;

}


我收到以下错误


"一个名为我的局部变量不能在这个范围内声明,因为它会给我赋予不同的含义,这已经在孩子中使用了。 />
范围表示其他内容

" NotYetaNurd" <否********* @ Matrix.com>在消息中写道

news:ec ************** @ TK2MSFTNGP10.phx.gbl ...
when i tried this
for(int i=0;i<6;i++)
{
for(int j=0;j<someConst;j++)
{
}
}

int i=1;
foreach(.......)
{
asdf=--i;
}

I am getting the following error

"A local variable named ''i'' cannot be declared in this scope because it
would give a different meaning to ''i'', which is already used in a ''child''
scope to denote something else
"NotYetaNurd" <No*********@Matrix.com> wrote in message
news:ec**************@TK2MSFTNGP10.phx.gbl...
for(int i = 0; i< 6; i ++)
{
//
}

在for循环后我不会超出范围......?
for(int i=0;i<6;i++)
{
//
}

wont i go out of scope after the for loop ...?



这篇关于范围问题:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆