首页 > Windows开发 > 详细

c#构造函数

时间:2015-09-15 10:41:52      阅读:143      评论:0      收藏:0      [点我收藏+]
 public class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入语文成绩和数学成绩");
            string x = Console.ReadLine();
            int c = x.IndexOf(",");
            if (c > 0)
            {
                int a = Convert.ToInt32(x.Substring(0, c));
                int b = Convert.ToInt32(x.Substring(c + 1));




                grades e = new grades(a, b);
                Console.WriteLine(e.ce());
            }
            else {
                Console.WriteLine("错误");
            }
            Console.ReadKey();
        }
    }
}
调用类

public
class grades { public int a; public int b; //public bool yun(int a, int b) { // if (a > 90 || b > 90) // { // return true; // } // else { // return false; // } //} public grades(int a,int b) { this.a = a; this.b = b; } public bool ce() { if (this.a > 90 || this.b > 90) { return true; } else { return false; } }

 

c#构造函数

原文:http://www.cnblogs.com/mengluo/p/4809261.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!