| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 347 人关注过本帖
标题:我是菜鸟,请各位前辈看一下问题在那里?
只看楼主 加入收藏
kaikai2008
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-6-1
结帖率:0
收藏
已结贴  问题点数:1 回复次数:1 
我是菜鸟,请各位前辈看一下问题在那里?
public partial class wecomle : System.Web.UI.Page
{
       public class car {
        private string colors;
      private int chel=4;
        public string Colors
        {
           
            set
            {
                colors = value;            
            }
            get
            {
                return colors;
            }
        }
        public int Chel
        {
            get
            {
                return chel;
            }
        }
        public string getinfo(string a, string b)
        {
            string c="  ";
            switch (a)
            {
                case "#red":
                    c += "你小车的颜色是红色<br>共有" + b + "个!";
                    break;
                case "#black":
                    c += "你小车的颜色是黑色<br>共有" + b + "个!";
                    break;
                case "#blue":
                    c += "你小车的颜色是蓝色<br>共有" + b + "个!";
                    break;
            }
            return c;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        car onecar = new car();
        onecar.Colors = DropDownList1.SelectedValue.ToString();
        string a = onecar.Colors.ToString();
        string b = onecar.Chel.ToString();
        string c = onecar.getinfo(a,b);
        Response.Write(c);

    }
    protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
    {

    }
}
选择颜色,没有显东西!好像swith块没有用?
搜索更多相关主题的帖子: 前辈 
2010-06-01 13:20
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:1 
public partial class wecomle : System.Web.UI.Page
{
       public class car
       {
          private string colors;
          private int chel=4;
          public string Colors
          {
           
            set
            {
                colors = value;            
            }
            get
            {
                return colors;
            }
         }
         public int Chel
         {
            get
            {
                return chel;
            }
         }
         public string getinfo(string a, string b)
         {
            string c="  ";
            switch (a)
            {
                case "#red":
                    c += "你小车的颜色是红色<br>共有" + b + "个!";
                    break;
                case "#black":
                    c += "你小车的颜色是黑色<br>共有" + b + "个!";
                    break;
                case "#blue":
                    c += "你小车的颜色是蓝色<br>共有" + b + "个!";
                    break;
             }
            return c;
         }
     }
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        car onecar = new car();
        onecar.Colors = DropDownList1.SelectedValue.ToString();
        string a = onecar.Colors.ToString();
        string b = onecar.Chel.ToString();
        string c = onecar.getinfo(a,b);
        Response.Write(c);

    }
    protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
    {

    }
}
看样子你这个创建的是内部类
2010-06-01 19:05
快速回复:我是菜鸟,请各位前辈看一下问题在那里?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019272 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved