首页 新闻 会员 周边

内嵌警告控制(VS2005)有什么作用

0
悬赏园豆:5 [已解决问题] 解决于 2008-03-26 16:44
<P>#pragma warning disable 618</P> <P>能否详细讲解下,这个起什么作用?</P>
问题补充: 程序完整例子 public static System.Collections.Specialized.NameValueCollection AppSettings { get { #pragma warning disable 618 return System.Configuration.ConfigurationSettings.AppSettings; #pragma warning restore 618 } }
编程入门的主页 编程入门 | 初学一级 | 园豆:185
提问于:2008-03-24 21:39
< >
分享
最佳答案
0
应该是消除.net版本/代码过期警告用的吧~~在使用这个语句的时候2.0的编译器会提示推荐使用 ConfigurationManager这个来访问配置文件.
沙加 | 老鸟四级 |园豆:3680 | 2008-03-24 23:27
其他回答(1)
0
#pragma warning disable 618 表示从这一行开始,本文件内如果触发了编号为0618的警告的话,不要提示. #pragma warning restore 618 则与上一个相反,从此行以后继续提示相关的警告. 在MSDN Library的索引页输入CS0618即可找到对应的编译警告说明: Compiler Warning (level 2) CS0618 Error Message 'member' is obsolete: '****' A class member was marked with the Obsolete attribute, such that a warning will be issued when the class member is referenced. The following sample generates CS0618: // CS0618.cs // compile with: /W:2 using System; public class C { [Obsolete("Use newMethod instead", false)] // warn if referenced public static void m2() { } public static void newMethod() { } } class MyClass { public static void Main() { C.m2(); // CS0618 } }
deerchao | 园豆:8367 (大侠五级) | 2008-03-25 00:33
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册