C# 數組,對象實例化並賦值


【數組】

數組實例化,並賦值時,可以省略new[]。

int[] a=new [2];                   --未賦值
int[] a={1,2};             --賦值

【對象】

對象實例化,並賦值時,可以省略()。

class test
{
  public string name{get;set;}
}

test a=new test();                      --未賦值
test a=new test{name="xiao"};  --賦值

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM