I'm learning C# now. Is an Int Array, value type or reference type?

I apologize as this is a basic question.

I'd like to know if an Int Array is a value type or a reference type.

I guess programming language doesn't matter, but I use C# now.

Many thanks in advance.
progloverAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonMiddle School Assistant TeacherCommented:
See "Value Types and Reference Types":
http://msdn.microsoft.com/en-us/library/t63sy5hs(VS.80).aspx

Under "Reference Types":

    "All arrays, even if their elements are value types"

So an int is a value type, but an array of int is a reference type.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MajorBigDealCommented:
Also, you can tell C# to treat a value as a reference by using the ref keyword.

        private void Example()
        {
            int i = 5;
            ChangeValue(i);
            int j = i; // i is still 5 at this point
            ChangeRef(ref i);
            int k = i; // now i is 6
        }

        private void ChangeValue(int i)
        {
            i = 6;
        }

        private void ChangeRef(ref int i)
        {
            i = 6;
        }
0
käµfm³d 👽Commented:
Also, you can tell C# to treat a value as a reference by using the ref keyword.
That's a tad misleading because the same can be said of out  = )
0
progloverAuthor Commented:
Thanks so much for the replies, Idle_Mind, MajorBigDeal and kaufmed.

I highly appreciate your time..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.