The Perfect Day

分享技术,编写未来

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
        public class PositionData
        {
            
private string name; //字段
            private string ticker;//字段
            private string shares;//字段

            
public PositionData()
            {

            }

            
public PositionData(string name, string ticker, string shares)
            {
                
this.name = name;
                
this.ticker = ticker;
                
this.shares = shares;
            }

            
public string Name //属性
            {
                
get
                {
                    
return name;
                }
            }

            
public string Ticker //属性
            {
                
get
                {
                    
return ticker;
                }
            }

            
public string Shares //属性
            {
                
get
                {
                    
return shares;
                }
            }
        }

        ArrayList values 
= new ArrayList();
        values.Add(
new PositionData("Microsoft""Msft""150 共享")); 
        values.Add(
new PositionData("Intel""Intc""25 共享")); 
        values.Add(
new PositionData("Dell""Dell""115 共享"));
        
foreach (PositionData da in values)
        {
           
if (da.Name == "Microsoft")
              MessageBox.Show(da.Name.ToString()
+" "+da.Ticker.ToString()+" "+da.Shares.ToString(),"Info");
        }



//******************************使用泛******************************//
        
    List
<PositionData> tmp = new List<PositionData>();
        tmp.Add(
new PositionData("Microsoft""Msft""150 共享"));
        tmp.Add(
new PositionData("Intel""Intc""25 共享"));
        tmp.Add(
new PositionData("Dell""Dell""115 共享"));
        
for (int i = 0; i < tmp.Count; i++)
            MessageBox.Show(tmp[i].Name 
+ " " + tmp[i].Ticker + " " + tmp[i].Shares, "Info");
posted on 2008-05-26 15:28  StephenJu  阅读(6885)  评论(0编辑  收藏  举报