What Does 'new' Do In C#? -


here's example of i'm talking about.

class car() {     int speed = 50; } 

now imagine in other file, do

car truck; 

how different from

car truck = new car(); 

i've been using c# little on year, still don't this. it's been on , off type of thing.

car truck; doesn't do anything. you're saying line of code may or may not have object of type car, , you'll want refer truck.

car truck = new car(); declares you've want refer car name truck (just before), also give name actual car object instantiating in place.

to continue car analogy (somewhat flawed) concept: car truck; parking spot, car truck = new car(); parking spot built new car in.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -