我如何将列表(字符串)传递给类中的writeonly属性 [英] How do I.. Pass a list (of string) to a writeonly property in a class

查看:162
本文介绍了我如何将列表(字符串)传递给类中的writeonly属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VB.Net v4.6 - VS2015



请使用以下代码:



我有一个带有一些属性的类(KeywordClass),一个带声明的模块



朋友_ImportKeywords作为新列表(字符串)

和a只写属性类:



VB.Net v4.6 - VS2015

Take the following code:

I have a class (KeywordClass) with some properties, a module with a declaration of

Friend _ImportKeywords As New List(Of String)
and a Write only property on the class of:

Public WriteOnly Property ImportKeywords() As List(Of String)
 Set(ByVal value As List(Of String))
        _ImportKeywords = value
    End Set
End Property



我试图将列表传递给来自课外的财产。




I am trying to pass a list to the property from outside of the class.

Dim Kwords As New List(Of String)
 Kwords.add("testing")
 Kwords.add("hello")
 Kwords.add("goodbye")







Using MyClass As New KeywordClass
  MyClass.ImportKeywords(Kwords)
  End Using





但我得到了错误:'Public WriteOnly属性ImportKeywords As List(O f String)'



如果有人可以帮助我,我会非常感激。谢谢您的时间:)



我尝试过:



我已经做了很多搜索,所有解决方案的结果似乎只是指向传递列表 - 这就是我上面所做的。似乎没有其他工作,我可能错过了显而易见的事实。 :/



but Im getting the error: Too many arguments to 'Public WriteOnly Property ImportKeywords As List(Of String)'

If someone can help me, I'd be very appreciative. Thanks for your time :)

What I have tried:

I've done a fair bit of searching and all the results that have been solutions seem to point to just passing the list - which is what I have done above. Nothing else seems to work and Im probably missing the obvious. :/

推荐答案

doh。应该是= kwords。我有多愚蠢。我的借口 - 这是一个漫长的漫长的一周,我很高兴它刚刚结束。感谢您的关注 - 也许是在明显的中学习的一课。干杯全部。
doh. should have been = kwords. How stupid can I get. My excuse - its been a long long week and Im just glad its just over. Thanks for looking - maybe a lesson to learn in "the obvious". Cheers all.


这篇关于我如何将列表(字符串)传递给类中的writeonly属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆