将字符串分配给string类型的属性 [英] Assigning a string to a property of type string
本文介绍了将字符串分配给string类型的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在尝试将字符串分配给string类型的属性。字符串包含值ADcgy9392tYrq...当我分配给属性变为A。这是我的代码
< serializable()>
公共类BeanstreamHash
私有_merchantID为长
公共财产MerchantID()为长
获取
返回_merchantID
结束获取
设置(ByVal值为长)
_merchantID = value
结束集
结束属性
私有_alphanumericValue As String
公共属性AlphanumericValue()As String
获取
返回_alphanumericValue
结束获取
设置(ByVal值为字符串)
_alphanumericValue = value
结束设置
结束物业
结束类
我将其分配给
Dim 结果作为 字符串 = DAL.GetAlphanumericValue(MerchantID)
如果 不结果 没什么 然后
beanstreamhash = 新 CommonObjects.BeanstreamHash
beanstreamhash.MerchantID = MerchantID
beanstreamhash.AlphanumericValue = result
RetVal.BeanstreamList.Add(beanstreamhash)
结束 如果
Catch ex As 例外
结束 尝试
返回 RetVal
结束 功能
请帮忙。
解决方案
Acco你的班级代码,不,它没有。所以要么你实际上是将字符串A分配给属性,要么你没有正确地解释某些东西,而你认为它只是字符串中的A。 / BLOCKQUOTE>
Hi All,
I am trying to assign a string to a property of type string.The string contains value "ADcgy9392tYrq"...When i assign to the property it becomes "A".Here is my code<serializable()> Public Class BeanstreamHash Private _merchantID As Long Public Property MerchantID() As Long Get Return _merchantID End Get Set(ByVal value As Long) _merchantID = value End Set End Property Private _alphanumericValue As String Public Property AlphanumericValue() As String Get Return _alphanumericValue End Get Set(ByVal value As String) _alphanumericValue = value End Set End Property End Class
and i am assigning it in
Dim result As String = DAL.GetAlphanumericValue(MerchantID) If Not result Is Nothing Then beanstreamhash = New CommonObjects.BeanstreamHash beanstreamhash.MerchantID = MerchantID beanstreamhash.AlphanumericValue = result RetVal.BeanstreamList.Add(beanstreamhash) End If Catch ex As Exception End Try Return RetVal End Function
Please help.解决方案According to your class code, no it doesn''t. So either you''re actually assigning the string "A" to the property, or you''re not interpreting something correctly and you think it''s only an "A" in the string.
这篇关于将字符串分配给string类型的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文