简体   繁体   English

Visual Studio C#2013 Express的解决方案资源管理器

[英]Solution Explorer for Visual Studio C# 2013 Express

I'm running VS 2013 Express targetting 4.5. 我正在运行VS 2013 Express,目标是4.5。 I have a Windows Forms test app called ConfigMgrTest2. 我有一个名为ConfigMgrTest2的Windows窗体测试应用程序。 Two questions as I move around the Solution Explorer: 在解决方案资源管理器中移动时,有两个问题:

(1) Using the Settings Designer tool, I created an Application setting called 'applicationSetting1'. (1)使用设置设计器工具,创建了一个名为“ applicationSetting1”的应用程序设置。 To access this setting, I need this syntax: 要访问此设置,我需要以下语法:

var r = ConfigMgrTest2.Properties.Settings.Default.applicationSetting1;

I don't understand why I need to call this through the Default property. 我不明白为什么我需要通过Default属性来调用它。 Both Default and 'applicationSetting' are members of the Settings class. Default和'applicationSetting'都是Settings类的成员。 And 'Default' pertains to the 'defaultInstance' Why not call my 'applicationSetting' directly like this: 和“默认”属于“ defaultInstance”,为什么不这样直接调用我的“ applicationSetting”:

var r = ConfigMgrTest2.Properties.Settings.applicationSetting1;

(2) The Settings class is created in two parts. (2)设置类分为两个部分。 In the Settings.Designer.cs file, the Default property is created. 在Settings.Designer.cs文件中,创建Default属性。 In Settings.cs, the Settings event handlers are created. 在Settings.cs中,将创建Settings事件处理程序。 In one of my projects, I can see the Settings.cs file in Solution Explorer but in another, I seem to be missing this node. 在我的一个项目中,我可以在解决方案资源管理器中看到Settings.cs文件,但在另一个项目中,我似乎缺少此节点。

Your setting ( applicationSetting1 in this case) is an instance member of the Settings class. 您的设置(在这种情况下为applicationSetting1 )是Settings类的实例成员。 The Default property represents an instance of that class via a Singleton pattern. Default属性通过Singleton模式表示该类的实例。 In order to do what you want to do in your second example you would constantly need to be creating an instance of Settings in your code, for example: 为了执行第二个示例中想要做的事情,您将不断需要在代码中创建一个Settings实例,例如:

var settings = new ConfigMgrTest2.Properties.Settings();
var r = settings.applicationSetting1;

This would be a pain for the develop and also potentially leave you with several instances of the class hanging around. 这将给开发人员带来痛苦,并可能使您陷入课堂上的几个实例中。

I just took a look in my copy of Visual Studio 2013 (Professional). 我只是看了一下我的Visual Studio 2013(专业版)副本。 I see the Settings.settings file, which is an XML file, and the Settings.Designer.cs file, which is the C# code that actually generates the Settings class code. 我看到Settings.settings文件(这是一个XML文件)和Settings.Designer.cs文件(这是实际上生成Settings类代码的C#代码)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio 2013扩展解决方案资源管理器筛选器 - Visual Studio 2013 Extending Solution Explorer Filter 如何在运行时将 c# 文件添加到 Visual Studio 解决方案资源管理器? - How to add a c# file to Visual Studio Solution Explorer at runtime? Visual Studio Express 2013-创建单独的C#代码文件? - Visual Studio Express 2013 - Create separate c# code file? 如何在visual studio 2013解决方案资源管理器中获取文件路径? - How to get a file path in visual studio 2013 solution explorer? 是否可以在Visual Studio 2013的解决方案资源管理器中手动标记文件 - Is it possible to manually flag files in the Solution Explorer in Visual Studio 2013 Visual Studio 2013 C#:一种解决方案使用另一种解决方案的代码 - Visual Studio 2013 C#: one solution consume code of another solution 如何使用Visual Studio Express 2013将C#接口实现/合并到简单的C ++程序中 - How to implement/merge C# interface into a simple C++ program using Visual Studio Express 2013 如何从Windows 8.1上的Visual Studio 2013 C#解决方案开始使用DirectInput? - How to get started with DirectInput from a Visual Studio 2013 C# solution on Windows 8.1? 如何从Visual Studio 2013中的C#解决方案生成序列图? - How can I generate Sequence Diagram from a C# solution in Visual Studio 2013? 在Visual Studio Express 2013中为C#项目的本地测试设置SQL数据库的最简单方法 - Easiest way to set up SQL Database for local testing of C# project in Visual Studio Express 2013
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM