المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : class vs structs in C#



C# Programming
11-15-2009, 02:00 PM
I am in the process of learning C sharp. Background is in C++ with some Java. Please
consider the following block of code:

class test3
{
private string[] strArray = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
}

Now, the above code compiles. However, if I make test3 a struct instead of a class, it does not.
This does not make any sense to me. Is there a reason for it?

Bob