草庐IT

Property

全部标签

properties - Swift 类 : Property not initialized at super. init 调用出错

我有两个类,Shape和SquareclassShape{varnumberOfSides=0varname:Stringinit(name:String){self.name=name}funcsimpleDescription()->String{return"Ashapewith\(numberOfSides)sides."}}classSquare:Shape{varsideLength:Doubleinit(sideLength:Double,name:String){super.init(name:name)//Errorhereself.sideLength=sideLe

properties - Swift 类 : Property not initialized at super. init 调用出错

我有两个类,Shape和SquareclassShape{varnumberOfSides=0varname:Stringinit(name:String){self.name=name}funcsimpleDescription()->String{return"Ashapewith\(numberOfSides)sides."}}classSquare:Shape{varsideLength:Doubleinit(sideLength:Double,name:String){super.init(name:name)//Errorhereself.sideLength=sideLe

c# - 如何将自定义属性添加到 WPF 用户控件

我有自己的用户控件,包括一些按钮等。我使用此代码将该UC显示在屏幕上。我已经向XXXX用户控件添加了两个属性,如Property1和Property2。并更改了我的代码当我将这2个参数添加到XAML页面时,系统抛出类似“成员‘Property1’无法识别或不可访问”的异常这是我的UC代码。publicpartialclassXXXX:UserControl{publiceventEventHandlerCloseClicked;publiceventEventHandlerMinimizeClicked;//publicboolShowMinimize{get;set;}publics

c# - 如何将自定义属性添加到 WPF 用户控件

我有自己的用户控件,包括一些按钮等。我使用此代码将该UC显示在屏幕上。我已经向XXXX用户控件添加了两个属性,如Property1和Property2。并更改了我的代码当我将这2个参数添加到XAML页面时,系统抛出类似“成员‘Property1’无法识别或不可访问”的异常这是我的UC代码。publicpartialclassXXXX:UserControl{publiceventEventHandlerCloseClicked;publiceventEventHandlerMinimizeClicked;//publicboolShowMinimize{get;set;}publics

c# - property.GetValue() 中的参数计数不匹配

这个问题在这里已经有了答案:ParameterCountMismatchexceptionwhencallingPropertyInfo.GetValue(3个答案)关闭7年前。我得到了parametercountmismatch错误。它出现在if子句中。我的代码:privateDictionaryObjectToDict(Dictionarydict,objectobj){varproperties=obj.GetType().GetProperties();foreach(varpropertyinproperties){if(property.GetValue(obj,null)

c# - property.GetValue() 中的参数计数不匹配

这个问题在这里已经有了答案:ParameterCountMismatchexceptionwhencallingPropertyInfo.GetValue(3个答案)关闭7年前。我得到了parametercountmismatch错误。它出现在if子句中。我的代码:privateDictionaryObjectToDict(Dictionarydict,objectobj){varproperties=obj.GetType().GetProperties();foreach(varpropertyinproperties){if(property.GetValue(obj,null)

c# - 如何使用 EPPlus 将 excel 行解析回类型

EPPlus有一个方便的LoadFromCollection将我自己类型的数据获取到工作表中的方法。例如,如果我有一个类:publicclassCustomer{publicintId{get;set;}publicstringFirstname{get;set;}publicstringSurname{get;set;}publicDateTimeBirthdate{get;set;}}然后是下面的代码:varpackage=newExcelPackage();varsheet=package.Workbook.Worksheets.Add("Customers");varcusto

c# - 如何使用 EPPlus 将 excel 行解析回类型

EPPlus有一个方便的LoadFromCollection将我自己类型的数据获取到工作表中的方法。例如,如果我有一个类:publicclassCustomer{publicintId{get;set;}publicstringFirstname{get;set;}publicstringSurname{get;set;}publicDateTimeBirthdate{get;set;}}然后是下面的代码:varpackage=newExcelPackage();varsheet=package.Workbook.Worksheets.Add("Customers");varcusto

c# - C# : "An object reference is required for the non-static field, method, or property" 错误

我在WPF中编写代码。首先,我编写了一个单独的项目来测试COMport的工作。设备,并且运行良好。接下来我决定将它集成到另一个项目中,但我得到了一个错误。我没有更改代码;我只是将它复制到一个新的代码文件中。此代码运行良好:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Windows;usingSystem.Windows.Controls;usingSystem.Windows.Data;usingSystem.Windows.Documents;usi

c# - C# : "An object reference is required for the non-static field, method, or property" 错误

我在WPF中编写代码。首先,我编写了一个单独的项目来测试COMport的工作。设备,并且运行良好。接下来我决定将它集成到另一个项目中,但我得到了一个错误。我没有更改代码;我只是将它复制到一个新的代码文件中。此代码运行良好:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Windows;usingSystem.Windows.Controls;usingSystem.Windows.Data;usingSystem.Windows.Documents;usi