| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 763 人关注过本帖
标题:新手编程,求解,我运行不出结果,大家可帮我看看是不是哪里出错了?
只看楼主 加入收藏
t120653918
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2014-7-18
结帖率:100%
收藏
 问题点数:0 回复次数:5 
新手编程,求解,我运行不出结果,大家可帮我看看是不是哪里出错了?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Student std1 = new Student();
            std1.stdno = "2013080452";
            std1.stdName = "张三";
            std1.stdSex = "男";
            std1.stdBir = new DataTime(1992, 1, 12);

            int age = std1.getAge();
            Console.WriteLine(age);

            Student std2 = new Student();
            std2.stdbir = new DataTime(1989, 5, 12);

            int age2 = std2.getAge();
            Console.WriteLine(age2);
        }
    }
}

class Student
{
    public string stdno;
    public string stdName;
    public string stdSex;
    public string stdBir;

    int getAge();
    {
        DaTatime nowTime=DaTatime.Now;
    return nowTime.Year-stdBir.Year;
    }
}
2014-07-18 11:36
Maick
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:32
帖 子:251
专家分:1314
注 册:2012-9-21
收藏
得分:0 
public string stdBir;
这个是string 类型..改成dataTime类型
2014-07-18 13:21
yanglin_gdqy
Rank: 2
等 级:论坛游民
威 望:3
帖 子:59
专家分:86
注 册:2013-12-2
收藏
得分:0 
接上,int getAge()后多了一个分号
2014-07-31 02:05
姚星星77
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-9-12
收藏
得分:0 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
      public   static void Main(string[] args)
        {
            Student std1 = new Student();
            std1.stdno = "2013080452";
            std1.stdName = "张三";
            std1.stdSex = "男";
            std1.stdBir = new DateTime(1992, 1, 12);

            int age = std1.getAge();
            Console.WriteLine(age);

            Student std2 = new Student();
            std2.stdBir = new DateTime(1989, 5, 12);

            int age2 = std2.getAge();
            Console.WriteLine(age2);
            Console.ReadKey();
        }
    }
}

            public class Student
            {
                public string stdno;
                public string stdName;
                public string stdSex;
                public DateTime stdBir;

               public  int getAge()
                {
                    DateTime nowTime=DateTime.Now;
                    return nowTime.Year-stdBir.Year;
                }
            }
2014-09-12 09:42
邓士林
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:淮河河畔
等 级:贵宾
威 望:61
帖 子:2392
专家分:13384
注 册:2013-3-3
收藏
得分:0 
赞一个,其实你那不叫不出结果,而是报错,Error

Maybe
2014-09-12 10:25
Misuzu
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2014-9-29
收藏
得分:0 
更新的新手表示学到了一点东西呢。。
2014-09-29 10:46
快速回复:新手编程,求解,我运行不出结果,大家可帮我看看是不是哪里出错了?
数据加载中...
 
   



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

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