我有2条记录但返回只有1个值 [英] I have 2 records but the return is only 1 value

查看:83
本文介绍了我有2条记录但返回只有1个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个头衔这个id。我想要返回两个值。但它只返回一个值。 

I have 2 leadtours for this id. I want to return both the values. But it is only returning one value. 

推荐答案

您需要返回List或Array或其他类型的集合。列表通常是最好的。

You need to return a List or Array or some other sort of collection. A List is usually best.

https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1?view=netframework-4.8

 public List<Tour> TourID
        {
            get 
            {
                List<Tour> list = new List<Tour>();
                foreach (Lead_Tour leadTour in LeadTours)
                {
                    if (leadTour != null)
                    {
                       list.Add(leadTour.ReserveTourID);
                    }
                }
                return list;
            }
            set { TourID = value; }
        } 


这篇关于我有2条记录但返回只有1个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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