从Web参考向对象分配属性 [英] Assigning properties to object from a web reference

查看:62
本文介绍了从Web参考向对象分配属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码在vb.net中生成了这两个故障排除提示
该代码的构建没有错误.
当本地人窗口停在试图设置address1的行上时,它在OrderContext下将所有内容列出为"Nothing",0.0或"False".

故障排除提示:
使用new关键字创建对象实例."
在调用方法之前检查以确定对象是否为空."


[代码开始]

The following code generates these two troubleshooting tips in vb.net
The code builds with no errors.
The locals window lists everything under OrderContext as "Nothing", 0.0 or "False" when it stop on the line which attempts to set address1.

Troubleshooting tips:
"Use the new keyword to create an object instance."
"Check to determine if the object is null before calling the method."


[code begin]

Imports TETest.com.nusa.cd.te2_ks
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim PEService As New PayService
        Dim OrderContext As New com.nicusa.cdc.tpe2_ks.WSOrderContext

        OrderContext.customer.address.address1 = "1233 Test Dr."
        OrderContext.customer.address.city = "Test City"
        OrderContext.customer.address.state = "KS"
        OrderContext.customer.address.zip = "66999"


[代码结尾]

[edit]添加了代码块[/edit]


[code end]

[edit]code block added[/edit]

推荐答案

构造函数New com.nicusa.cdc.tpe2_ks.WSOrderContext是否也创建了一个customer实例,或者是OrderContext.customer Nothing?
我猜就是这样.因此,还要构造一个客户对象(可能还有一个地址对象),并设置属性.
Does the constructor New com.nicusa.cdc.tpe2_ks.WSOrderContext also create an instance of customer, or is OrderContext.customer Nothing?
I guess that''s what happens. Hence, also construct a customer object, and likely also an address object, and set the properties.


这篇关于从Web参考向对象分配属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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