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

问题描述

我有这样的代码..



  class  ABC 
{
public string 姓名,电话;

public static IEnumerable< ABC> GetList()
{
List< ABC> foo = new 列表< ABC>();

// 这里有一些COED
return foo;
}
}

A类
{
私有 void GetList()
{
IEnumerable< ABC> abc = ABC.GetList();
foreach (ABC newitem in abc)
{
ListViewItem li = new ListViewItem();
li.Text = newitem.Name;
li.Tag = newitem; // <<<<<<<<<<<<< <这可能吗 ???
ListView1.Items.Add(li);
}
}
}







我想知道如果我可以将一个对象分配给ListViewItem的Tag属性??

为什么它可以在外面访问,因为该对象位于一个函数内?

它会导致任何问题在未来 ??记忆等.... :(请Helpp :(

解决方案



I have a code like this..

class ABC
{
   public string Name, Phone;

   public static IEnumerable<ABC> GetList()
   {
      List<ABC> foo = new List<ABC>();

      //Some COde here
      return foo;
   }
}

Class A
{
   private void GetList()
   {
      IEnumerable<ABC> abc = ABC.GetList();
      foreach (ABC newitem in abc)
      {
         ListViewItem li = new ListViewItem();
         li.Text = newitem.Name;
         li.Tag = newitem; //<<<<<<<<<<<<< Is this Possible ??? 
         ListView1.Items.Add(li);
      }
   }
}




I want to know If I can assign an object to the Tag Property of ListViewItem ??
How come it be accessible outside since the object resides inside a function ??
Will it cause any problems in future ?? Memory and so.... :( Please Helpp :(

解决方案



这篇关于将对象分配给标记属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 20:33