草庐IT

NSString-Property

全部标签

c# - 属性(property)(没有额外处理)与公共(public)领域

这个问题在这里已经有了答案:Whatisthedifferencebetweenafieldandaproperty?(33个答案)关闭3年前。每当有关于属性可信度的问题时,我发现大部分讨论都是围绕函数/方法与属性展开的。但我也想知道令人信服的原因,即直接使用具有关联私有(private)字段的属性与公共(public)字段本身,以防最常见的获取/设置行为没有其他处理,我的意思是这样publicstringCustomerName;对比privatestringcustomerName;publicstringCustomerName{get{returncustomerName;}s

c# - 流利的 NHibernate "Could not resolve property"

我已经阅读了很多关于相同错误的问题,但没有一个与我的确切问题相匹配。我正在尝试使用FluentNHibernate访问一个对象的属性,该对象本身是根对象的一部分。一些答案说我需要使用投影,其他人说我需要使用连接,我认为它应该通过延迟加载来工作。这是我的两个类以及Fluent映射:美术课publicclassArtist{publicvirtualintId{get;set;}publicvirtualstringName{get;set;}publicvirtualIListAlbums{get;set;}publicvirtualstringMusicBrainzId{get;set

C# WPF 附加属性 - 错误 : "The property does not exist in XML namespace"

我需要为现有的WPF控件(组框、文本框、复选框等)创建一个新属性,该属性将存储其访问级别,因此我找到了附加属性。我以这个网站为例http://dotnetbyexample.blogspot.com.br/2010/05/attached-dependency-properties-for.html一切都很好,但是当我尝试在某些控件上使用它时出现以下错误...Error1Theproperty'DependencyPropertiesHoster.AcessLevel'doesnotexistinXMLnamespace'clr-namespace:ImageGUI.App_Code;

c# - EF4 代码优先 : how to add a relationship without adding a navigation property

我应该如何在不使用任何导航属性的情况下使用CodeFirst来定义关系?之前,我通过在关系的两端使用导航属性来定义一对多和多对多。并在数据库中创建适当的关系。这是类外观的精简版本(为简单起见,我已将多对多关系转换为一对多)。publicclassUser{publicstringUserId{get;set;}publicstringPasswordHash{get;set;}publicboolIsDisabled{get;set;}publicDateTimeAccessExpiryDate{get;set;}publicboolMustChangePassword{get;set

c# - 有没有理由拥有没有 setter/getter 的属性(property)?

我的经理问我使用带有setter而没有getter的属性是否是好的做法。publicclassPropertyWrapper{privateMyClass_field;publicMyClassProperty{set{_field=value;}}publicstringFirstProperty{get{return_field.FirstProperty;}}publicstringSecondProperty{get{return_field.SecondProperty;}}}他将使用其他属性来公开私有(private)字段中的属性,由该setter设置。我的建议是只使用私有

c# - 在 WPF 中获取 "<Property Name> was already registered by "<控件名称>"错误

我在WPF中有一个用户控件,它绑定(bind)到一个依赖属性。当我尝试编译应用程序时,出现“属性名称”已由“控件名称”注册的错误,设计器显示“无法创建“用户控件”的实例”错误。这是我的简单控件的样子:ExampleUserControl.xaml:ExampleUserControl.xaml.cs:publicpartialclassExampleUserControl:UserControl{publicDependencyPropertySomeStringValueProperty=DependencyProperty.Register("SomeStringValue",ty

c# - 内部 protected 属性(property)仍然可以从不同的程序集访问

我正在为有关辅助功能的初学者session设置一些演示代码,我发现我能够从派生类访问内部protected属性。我错过了什么?程序集1namespaceAccessibility{classProgram{staticvoidMain(string[]args){ExampleClassc=newExampleClass();c.Go();//c.Prop1=10;}}classExampleClass:DerivedClass{publicvoidGo(){this.Prop1=10;this.Prop2=10;//this.Prop3=10;//Doesn'twork//this.

c# - 找不到段 'Property' 的资源

当使用ADO.Net数据服务客户端通过调用LoadProperty刷新实体时:ctx.BeginLoadProperty(this,"Owner",(IAsyncResultar)=>...如果属性为null,它会在服务器上抛出一个错误Error:ExceptionThrown:System.Data.Services.DataServiceException:Resourcenotfoundforthesegment'Owner'.atSystem.Data.Services.RequestDescription.GetSingleResultFromEnumerable(Segme

c# - 具有 "has property X"约束的通用函数?

我有一个导出COM接口(interface)的第三方闭源应用程序,我通过Interop在我的C#.NET应用程序中使用它。此COM接口(interface)导出许多对象,这些对象都显示为System.Object,直到我将它们转换为适当的接口(interface)类型。我想为所有这些对象分配一个属性。因此:foreach(objectxinBigComInterface.Chickens){(xasChicken).attribute=value;}foreach(objectxinBigComInterface.Ducks){(xasDuck).attribute=value;}但是

c# - EF4.1 代码优先 : How to disable delete cascade for a relationship without navigation property in dependent entity

假设我有这两个非常基本的实体:publicclassParentEntity{publicintId;publicvirtualICollectionChildrens;}publicclassChildEntity{publicintId;publicintParentEntityId;//ForeignKeypublicvirtualParentEntityparent;//[NOTWANTED]}出于某些原因,我不希望ChildEntity保留对其父项的引用。我只希望它保留ParentEntityid但仅此而已。到目前为止,没问题,我只是删除了[NOTWANTED]行,一切都按预