Classes vs Structures

 Both Can Contain Members : Fields & Methods

 Both Require a Constructor to Create a new instance of themselves , and Like All Types

 in the .Net Framework Both Inherited From Object.


Key Difference : Classes Are Reference Types & Structs Are Value Types


On a Low Level : Instances Data of Classes is Allocated on the Heap. 

Instances Data of Structs is Allocated on the Stack.


Access To The Stack is Designed to be Light and Fast ! But Storage of Large 

Amounts of Data on The Stack Can Impede overall Application Performance.


Structs Are Best Used for Smaller , Lightweight Objects that Contain Relatively 

Little Instance Data or For Objects that dont Persist For Long.


Classes Are Best Used for Larger Objects that Contain More Instance data and are 

Expected To Exist in Memory for Extended Periods.


----


More Information


نظرات 2 + ارسال نظر
محبوب یکشنبه 4 تیر 1391 ساعت 11:55 ق.ظ

باسلام
استاد خیلی خیلی ممنون که این مطلب رو در اختیارمون قرار دادین.

You`re Welcome

یلدا یکشنبه 4 تیر 1391 ساعت 11:19 ب.ظ

سلام استاد
خیلی خوب بود
ممنون

برای نمایش آواتار خود در این وبلاگ در سایت Gravatar.com ثبت نام کنید. (راهنما)
ایمیل شما بعد از ثبت نمایش داده نخواهد شد