Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Reference types

Quick reminder: Any object you have to instantiate (e.g. create with the new keyword) is what’s called a Reference Type. It means that, when used as a method parameter, it will always be treated as a reference parameter (ref in C#, ByRef in VB).

In other words, this is redundant:

  1: void ModifyData(ref DataSet data)
  2: {
  3:     //....
  4: }

Because DataSet is a Reference Type, the ref keyword in the above examples serves no use. 

Opposite to Reference Types are Value Types, like an int or a string. They have to specify the ref keyword in the parameter if they want to be treated as such.

Here’s a good article on reference and value types.

See ya.



This post first appeared on Hugonne - Another .net Coding, please read the originial post: here

Share the post

Reference types

×

Subscribe to Hugonne - Another .net Coding

Get updates delivered right to your inbox!

Thank you for your subscription

×