lwj_C#_方法重载,递归,构造

来源:互联网 发布:linux还原备份命令 编辑:程序博客网 时间:2024/04/30 16:47
class Text{
//        //方法重载
//        public  int Mulit(int a, int b){
//            return a * b;    
//        }
//        public float Mulit( float a, float b){
//            return a * b;
//        }
//        public double Mulit(double a, double b){
//            return a * b;
//        }
//
//        //递归   一定要有出口  递了要归  来理解
//        public int Factorial(int n){
//            if (n == 1) {
//                //出口
//                return 1;
//            }
//            return n * Factorial (n - 1);
//        }
//        public int Fib(int n){
//            if (n == 1 ||n == 2) {
//                return 1;
//            }
//            return Fib (n - 1) + Fib (n - 2);
//        }
//        public int Sum(int n){
//            if (n == 1) {
//                return 1;
//            }
//            return n + Sum (n - 1);

//        }


//    public enum Gender{
//        man,
//        woman
//    }
//    public class Person
//    {
//        public string name;
//        public int age;
//        public Gender gender;
//        public int id;
//        public Person ()
//        {
//        }
//        //自定义构造方法
//        public Person (string name, int age, Gender gender, int id){
//            this.age = age;
//            this.name = name;
//            this.gender = gender;
//            this.id = id;


原创粉丝点击