使用在不同范围内声明的Goto,并在c#win中调用不同的范围。形成 [英] Use Goto which is declared in a different scope and called in a different scope in c# win. form

查看:100
本文介绍了使用在不同范围内声明的Goto,并在c#win中调用不同的范围。形成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮我查询



Can somebody help me with my query

if(chk1.Checked == true)
{
    if(chk2.Checked.Checked == true)
    {
        chk4.Checked == true;
        //from here the pointer should goto (1) statement
    }
}
else
{
    //here i want to send the pointer              (1)
    chk3.Checked == false;
}





如何将指针从第6行发送到第11行

推荐答案

在C#中不鼓励使用指针:它们可用,但只有在您更改项目以允许不安全代码时才可用使用 unsafe 关键字: http:// msdn。 microsoft.com/en-us/library/chfa2zb8.aspx [ ^ ]



这里有一个教程: http://msdn.microsoft.com/en-us/library/aa288474(v = vs.71).aspx [ ^ ]关于不安全代码,但说实话,如果你试图使用它并且你不知道你在做什么,那么你可能已经得到了你的项目设计翁。在处理不是用C#编写的外部代码时(或大部分时间,甚至不是那时),或者在一小段代码中需要严格的性能时,你应该只需要指针。在这两种情况下,如果您还不知道如何使用它,您可能根本不需要这样做。
Pointers are discouraged in C#: they are available, but only when you change your project to permit unsafe code and also use the unsafe keyword: http://msdn.microsoft.com/en-us/library/chfa2zb8.aspx[^]

There is a tutorial here: http://msdn.microsoft.com/en-us/library/aa288474(v=vs.71).aspx[^] on unsafe code, but to be honest, if you are trying to use it and you don;t know what you are doing, then you have probably got the design of your project wrong. You should only need pointers when dealing with external code not written in C# (and most of the time, not even then) or when you need serious performance in a small chunk of code. In both cases, if you don't already know how to use this, you probably shouldn't need to do it at all.


将指针发送到(1)是毫无意义的 ':-)。



即使技术上可行,因为 C#编程语言具有 goto 声明,这将是使用后者的非常糟糕的方法之一。



你可以达到同样的效果(如果这是有道理的)添加声明

Sending 'pointer' to (1) is 'pointless' :-).

Even if technically feasible, since the C# programming language features the goto statement, it would be one of the very bad ways to use the latter.

You could accomplish the same effect (if it makes sense) adding the statement
chk3.Checked == false;



就在下方(或上方)


just below (or just above ) the

引用:

//从这里指针应该转到(1)语句

//from here the pointer should goto (1) statement



line。


line.


这篇关于使用在不同范围内声明的Goto,并在c#win中调用不同的范围。形成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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