dart中的类与对象

  void main(){
      var person = new Pesron();//new 可以省略
      person.name = "Tom";
      person.age = 20 ;
      print(person.name);
      person.work();
  
  }
  class Pesron{
     String name;
     int age;
     void work(){
       print('Name is $name,Age is $age,He is working...');
     }
  }

20200806165019.png

Last modification:August 6th, 2020 at 04:53 pm
如果觉得我的文章对你有用,请随意赞赏