我有一个CibilResponse类,它具有类类型(TUEF类)的属性。我正在尝试为CibilEnquiryEnq.Tuef.Version
分配值,但我得到空引用错误。在你将这个问题标记为重复之前,让我提一下我已经阅读了一些类似的问题及其在SO上的答案以及我在构造函数中初始化tuef的帖子,正如你在我的代码中看到的那样。你能否指出你能做什么,我做错了什么?
ICIBIL.cs
[ServiceContract]
public interface ICIBIL
{
[OperationContract]
string InsertCibil(CibilResponse cibilResponse);
[OperationContract]
string GenerateEnquiry(CibilEnquiry testObj);
}
[DataContract]
public class CibilResponse
{
[DataMember]
public string ResponseString { get; set; }
[DataMember]
public string Business { get; set; }
[DataMember]
public string MkrId { get; set; }
}
[DataContract]
public class CibilEnquiry
{
[DataMember]
public TUEF Tuef { get; set; }
public CibilEnquiry()
{
this.Tuef = new TUEF();
}
}
[DataContract]
public class TUEF
{
[DataMember]
public string SegmentTag { get; set; }
[DataMember]
public string Version { get; set; }
[DataMember]
public string MemberReferenceNumber { get; set; }
}
申请:
CibilWcfService.CIBIL obj = new CibilWcfService.CIBIL();
CibilWcfService.CibilEnquiry CibilEnquiryEnq = new CibilWcfService.CibilEnquiry();
CibilEnquiryEnq.Tuef.Version = "123";// null reference error here
string res = obj.GenerateEnquiry(CibilEnquiryEnq);
答案 0 :(得分:3)
你能尝试以下吗? C#区分大小写。
<div class="row col2">
<?php echo $form->labelEx($model,'visited_date'); ?>
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker',array(
'model' => $model,
'attribute'=>'visited_date',
'options'=>array(
'showAnim'=>'drop',//'slide','fold','slideDown','fadeIn','blind','bounce','clip','drop'
'dateFormat' => 'yy-mm-dd',
'showButtonPanel' => true,
),
'htmlOptions'=>array('size'=>30,'class'=>'date', //'value'=> date("Y-m-d")
),
));
?>
<?php echo $form->error($model,'visited_date'); ?>
</div>
<div class="row col2">
<?php echo $form->labelEx($model,'next_visited_date'); ?>
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker',array(
'model' => $model,
'attribute'=>'next_visited_date',
'options'=>array(
'showAnim'=>'drop',`enter code here`
'dateFormat' => 'yy-mm-dd',
'showButtonPanel' => true,
),
'htmlOptions'=>array(
'style'=>'height:20px; border-color: #448844;color:red; float:left;',
),
));
?>
<?php echo $form->error($model,'next_visited_date'); ?>
</div>
答案 1 :(得分:2)
这可能会为你做到这一点
$query = "select id, author_name, whatever from author";
$author_records = $database->Execute($query);
foreach ($author_records as $fields) {
echo "Author: {$fields['author_name']} whatever <br/>";
$subquery = "select whatever from books where id = whatever";
$book_records = $database->Execute($subquery);
foreach ($book_records as $otherfields) {
echo "Book whatever whatever";
}
}