草庐IT

late-initialized-properties

全部标签

c# - 如何解决 ReSharper 仅针对显示/值成员的属性的 "unused property"警告?

我已经为一个对象定义了两个属性,“Name”和“ID”,我将其用于具有BindingList数据源的ComboBox的DisplayMember和ValueMember。我最近安装了ReSharper来评估它。ReSharper在对象上向我发出警告,指出这两个属性未被使用。示例代码:BindingListSampleList=newBindingList();//populateSampleListcmbSampleSelector.DisplayMember="Name";cmdSampleSelector.ValueMember="ID";cmbSampleSelector.Dat

Cucumber extend reports的extent.properties配置

extent.reporter.spark.class=tech.grasshopper.reporters.ReporterAdapter$SparkReportAdapterextent.reporter.json.class=tech.grasshopper.reporters.ReporterAdapter$JsonReportAdapterextent.reporter.pdf.class=tech.grasshopper.reporters.ReporterAdapter$PDFReportAdapterextent.reporter.html.class=tech.grassho

c# - 多线程,Task.Run 错误 'The call is ambiguous between the following methods or properties'

当我尝试构建项目时,显示以下错误消息。Thecallisambiguousbetweenthefollowingmethodsorproperties:'System.Threading.Tasks.Task.Run(System.Action)'and'System.Threading.Tasks.Task.Run(System.Func)'我该如何解决这个问题?publicstaticclassMaintananceManager{privatestaticThreadSafeSocialMediaListPostList=newThreadSafeSocialMediaList(

c# - ASP.NET Core 浏览器链接 `Unable to get property ' 文件'`

在MicrosoftVirtualAcademy类(class)中'IntroductiontoASP.NETCore(formerlyASP.NET5)',视频3,在39:00,他们演示了BrowserLink如何在Edge的F12工具和VisualStudio之间同步代码选择。我还没有看到开箱即用的相同功能。我不知道是否有设置或特殊功能来启用此功能。如果有,它没有在类(class)视频中显示,但视频又是几个月前的了。我以前从未见过此功能。BrowserLink从Edge连接到VisualStudio,在VS中的BrowserLinkDashboard中可以看到。没关系。Edge中有

c# - Entity Framework : StoreGeneratedPattern ="Computed" property

我有一个DateTime属性。我需要此属性的默认值为DateTime.Now。然后我发现您可以在SQL中指定一个属性StoreGeneratedPattern="Computed"并将其设置为(getdate())。这成功了。但我无法在代码中更改此属性。有时我需要将此属性更改为任何DateTime值。但是我的更改没有保存。 最佳答案 将此属性设置为Computed是在告诉EF您不能直接设置该值。你怎么能?此属性是为了计算列而存在的,根据定义,计算列不会保存回数据库。不幸的是,EF的“默认值”属性只能设置为编译时已知的值,因此不能设置

C# 编译器错误 : "cannot have instance field initializers in structs"

我需要有关结构的建议。我有两段代码。第一部分如下:namespaceProject.GlobalVariables{classIOCard{structInputCard{publicstringCardNo;publicintBaseAddress;publicintLowerAddress;publicintUpperAddress;publicint[]WriteBitNo=newint[16];publicint[]ReadBitNo=newint[16];}staticInputCard[]InputCards=newInputCard[5];publicstaticstri

c# - 公约问题: When do you use a Getter/Setter function rather than using a Property

令我印象深刻的是,在尝试操作类中的字段时应该使用C#中的属性。但是当涉及到复杂的计算或数据库时,我们应该使用getter/setter。这是正确的吗?什么时候对属性使用s/getter? 最佳答案 .NET设计指南在Propertiesvs.Methods中提供了这个问题的一些答案。部分。基本上,属性与字段具有相同的语义。你不应该让一个属性抛出异常,属性不应该有副作用,顺序不重要,属性应该相对快速地返回。如果这些事情中的任何一个可能发生,最好使用一种方法。该准则还建议使用返回数组的方法。在决定是使用属性还是方法时,如果我将其视为字段

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# - WebKit.Net 和 OpenWebKitSharp 错误 : Failed to initialize activation context

我同时使用/或者使用WebKit.Net和OpenWebKitSharp。但是,一旦我尝试实例化WebKitBrowser,我就会收到错误消息:无法初始化激活上下文有人知道这是什么吗? 最佳答案 只有当您的exe文件夹中缺少OpenWebKitSharp.manifest和其他WebKit文件时,才会发生此错误。尝试将每个文件从“核心”文件夹复制到您的调试/发布目录。 关于c#-WebKit.Net和OpenWebKitSharp错误:Failedtoinitializeactivati