网址代码没有违反建设 [英] Url in code not breaking build

查看:169
本文介绍了网址代码没有违反建设的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个演示中,我看到了一段测试代码,开发人员已经在代码粘贴URL时。当开发者构建应用程序的一切工作,但是我们在这里一切都非常好奇,为什么编译器所接受的URL为行。

During a demo I saw a piece of test code where the developer had pasted an url in the code. And when the developer build the application everything worked, but we where all very curious why the compiler accepted the url as a line.

public class Foo
{
   // Why doesn't 'http://www.foo.org' break the build?
    public void Bar()
    {
        http://www.foo.org
        Console.WriteLine("Do stuff");
    }
}



为什么上面生成的代码?编译器将线路作为一个评论?

Why does the code above build? Does the compiler treat the line as a comment?

推荐答案

如果您尝试上述确切的代码,你会得到警告CS0164:该标签还没有被引用

If you try the exact code above, you get warning CS0164: This label has not been referenced.

警告这里提供了一个明确的提示,发生了什么事。

The warning here offers a clear hint as to what has happened.

粘贴URL已创建的标签 HTTP:,例如:与转到使用,紧跟一个单行注释, //www.foo.org

Pasting the URL has created a label http:, e.g. for use with goto, immediately followed by a single-line comment, //www.foo.org.

这篇关于网址代码没有违反建设的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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