List<T_Kind> tk_father;(该List里有T_Kind对象)我想判断 int i==这个List中每个T_Kind对象的K_ID属性不知道怎么写,求教大神~~

解决方案 »

  1.   

    for(int i = 0; i < tk_father.Count; i++)
    {
        //to do
    }
    //=====================//
    foreach(T_Kind tk in tk_father)
    {
        //to do
    }
      

  2.   

    直接把List里面的T_Kind对象给取出来
    这样;for(i=0;i<th_father.count;I++)
    {
        t_Kind kind = tk_father[i];
         kind.k_id;
        
    }
      

  3.   


    for(int i=0;i<father.Count();i++){   father[i].T_Kind.K_ID //你要的属性}
      

  4.   

    for(int j=0;j<tk_father.count;j++)
    {
      if(i==tk_father[i].k_ID)
         {
          ........
         }
    }
      

  5.   

    List<T_Kind> tk_father=new List<T_Kind>();
    foreach(T_Kind t in tk_father)

     if(t.K_ID==i){}
    }
      

  6.   

    楼上的正解。
    遍历list,foreach 或者for循环取值即可。
      

  7.   

    (where(T_Products p) { return p.P_Kind == Convert.ToInt32(i) || p.P_Kind==tk_father[对象的K_ID属性]   });我这2个是在一起的,我尝试把循环写到这里面,但是写都写错了,出不来。
      

  8.   


    foreach(T_Kind tk in tk_father)          //用 foreach遍历List
    {
        if(tk.K_ID==i)
         {
            //这里写你的处理代码
         }
    }
      

  9.   

    不是,你可能还没弄清我的意思。
    我是想p.P_Kind==(这个地方遍历出list中对象的每个K_ID属性)
      

  10.   

    直接把List里面的T_Kind对象给取出来
    这样;for(i=0;i<th_father.count;I++)
    {
      t_Kind kind = tk_father[i];
      kind.k_id;
        
    }
      

  11.   

    p.P_Kind==(或者可以理解成是:list中T_Kind对象的K_ID) 是一个意思
      

  12.   


    你们可能没明白我的意思吧!p.P_Kind==(或者可以理解成是:list中T_Kind对象的K_ID)这里就是引用的后面那个判断条件,tk_father是list。我是想让他在这个做判断的条件里面:
    (where(T_Products p) { return p.P_Kind == Convert.ToInt32(i) || p.P_Kind==【就是在这里判断是否等于List<T_K>中T_K对象的K_ID】 ;});这样你们明白了吗?