如何解决此警告. [英] How to solve this Warning.
问题描述
[StructLayout(LayoutKind.Sequential)]
public struct STATURL
{
#region FIELD AREA ******************************************
/// <summary>
/// Last visited date (UTC)
/// </summary>
public FILETIME ftLastVisited;
/// <summary>
/// URL
/// </summary>
[MarshalAs(UnmanagedType.LPWStr)]
public string url;
要使用UrlHistory,我编写了此代码.我使用url,但不使用ftLastVisited这样的FileTime.我不需要"public FILETIME ftLastVisited".
当我不使用"public FILETIME ftLastVisited"这一行来操作项目时,该项目出错.但是,当我将代码输入为"public FILETIME ftLastVisited"时,该项目发出了警告.警告说此变量不要在项目中使用.
我认为即使该项目不使用该代码,该项目也需要代码来运行该项目.但是我不想在删除代码时犯错误.
因此,您能给我一些解决此问题的建议吗?
To use UrlHistory I made this code. I use url, but I don''t use FileTime like ftLastVisited. I don''t need "public FILETIME ftLastVisited".
When I operated the project without the line as "public FILETIME ftLastVisited", the project made Error. But when I input the code as "public FILETIME ftLastVisited", the project made a warnings. the warning says that this variable don''t be used in the project.
I think that the project need the code to run the project, even if the project don''t use the code. However I want not to make erroring as deleting the code.
So Could you give me advice to solve this problem?
推荐答案
我认为您对警告的解释不正确.如果从未使用过某些变量或类或结构的成员,则警告您,但如果它是公共的,则不会警告.出于明显的原因,公开被认为使用得足够好".我有什么建议?切勿警告.首先,确保您的警告为零,然后继续.当您收集警告时,您最终会开始忽略它们.这实际上将警告等有价值的工具从您的工作中排除了.
原则是:不要与破损的窗户一起生活! (我的意思是小写的"windows".也不要与坏掉的Windows一起使用.:-))
SA —
I think you inaccurately explained the warning. You get warning if some variable or a member of a class or structure is never used, but not if it is public. Being public is considered as "used well enough", by the apparent reason. What can I advise? Never work with warning. First, make sure you have zero warnings, then go ahead. When you collect warnings, you eventually start ignoring them. This effectively exclude such a valuable instrument as warnings from your work.
The principle is: don''t live with broken windows! (I mean "windows" in low case here. Don''t live with broken Windows also. :-))
SA—
这篇关于如何解决此警告.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!