构造函数

 

    public class Vector3
    {
          public float x,y,z,length;
        public Vector3()
        {
            Console.WriteLine("Vector被调用了");
        }
        public Vector3(float x,float y,float z){
            this.x=x;
            this.y=y;
            this.z=z;
            length=Length();
        }
        public float Length(){
            return(float)Math.Sqrt(x*x+y*y+z*z);
        }
    }
}
//
using System;

namespace c构造函数
{
    class Program
    {
        public static void Main(string[] args)
        {
            Vector3 v1=new Vector3(1,1,1);
            
            Console.WriteLine("Hello World!");
            
            // TODO: Implement Functionality Here
            
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
    }
}

 

posted @ 2018-10-31 21:32  逐梦武威  阅读(82)  评论(0编辑  收藏  举报