c# - How Does Knowing Ref and Val types Help -


i have been reading on reference , value types. idea. how me while coding? don't have examples understand times knowing stuff helps.

it means can understand code going do.

it's kinda hard write code when can't predict effects of given statement be, due not knowing type system semantics.

for example, suppose don't know how reference types work, , presented code:

stringbuilder builder = new stringbuilder(); stringbuilder other = builder; builder.append("foo"); other.append("bar"); console.writeline(builder); 

we know that print "foobar" because stringbuilder reference type - second line copying reference, not creating object. if didn't understand how reference types behave, might have expected print "foo".


Comments

Popular posts from this blog

400 Bad Request on Apache/PHP AddHandler wrapper -

Add email recipient to all new Trac tickets -

php - Change action and image src url's with jQuery -