如何将observablecollection放入列表
问题描述:
你好
我想将observablecollection放入List< string>像这样:
Hello
I want to put observablecollection into the List<string> like this :
<pre lang="cs">List<string> test = new List<string>();<br />
foreach (CheckInData coll in CheckInCollection)<br />
{<br />
for (int i = 0; i < _CheckInCollection.Count; i++)<br />
{<br />
test.Add(coll.RoomNumber[i].ToString());<br />
}<br />
<br />
}</pre><br />
但它仅将集合的第一个字符作为示例,例如,有2424个测试内容将仅为2个.
请任何人帮助我
这是我的收藏集:
but its only put the first character of collection for example there is 2424 test content will be only 2.
Please help me anybody
This is my Collection:
<pre lang="cs">ObservableCollection<CheckInData> _CheckInCollection = new ObservableCollection<CheckInData>();<br />
<br />
public ObservableCollection<CheckInData> CheckInCollection<br />
{<br />
get { return _CheckInCollection; }<br />
}<br />
public class CheckInData<br />
{<br />
public string RoomNumber { get; set; }<br />
public decimal Price { get; set; }<br />
public string Currecny { get; set; }<br />
public decimal Discount { get; set; }<br />
public string CheckOut { get; set; }<br />
public int TotalDay { get; set; }<br />
public decimal TotalPrice { get; set; }<br />
public int CheckOutYear { get; set; }<br />
public int CheckOutMonth { get; set; }<br />
public int CheckOutDay { get; set; }<br />
public Boolean IncToday { get; set; }<br />
}</pre><br />
答
要在列表中放入什么?RoomNumber
?
也许这会帮到您...不是最好的解决方案...但这是一个;)
What do want to put in your List? TheRoomNumber
?
Maybe this will help you... not the best solution... but it is one ;)
List<string> test = new List<string>();
foreach (CheckInData checkInData in CheckInCollection)
{
if (!test.Contains(checkInData.RoomNumber))
test.Add(checkInData.RoomNumber);
}
</string></string>
将变量coll
重命名为checkInData
...
Renamed the variable coll
into checkInData
...