我只是想知道在课堂上使用这个关键字与类变量是好习惯还是坏?
如果我使用它会减少或增加应用程序的运行时间/编译时间吗?如下: -
this.FirsName = cust.name;
this.LastName = cust.Lname;
this.Age = cust.age;
this.DOB = cust.dob;
等等超过1000行代码......
它不会影响您的编译时间或运行时间。这也不是一个好习惯。
使用this
关键字的原因是将类别道具分离到特定部分内的另一个属性。
如果您谈论代码约定和样式,只需采用Microsofts:
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/inside-a-program/coding-conventions
你应该阅读Microsoft文档:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/this