tag:blogger.com,1999:blog-8821078224593983074.post1346597201713436133..comments2007-07-04T13:55:18.815-05:00Comments on .NET Interview Question: What is the difference between classes and structs...Gurjinder Singh Brarhttp://www.blogger.com/profile/11418457142219631635noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-8821078224593983074.post-79255414675013663892007-07-04T13:55:00.000-05:002007-07-04T13:55:00.000-05:00Can someone give an example of Structures implemen...Can someone give an example of Structures implementing interfaces?<BR/>I thought structures are as good as user defined types.Swatihttp://www.blogger.com/profile/05283509545717841801noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-82176705907108404512007-06-08T03:33:00.000-05:002007-06-08T03:33:00.000-05:00Structures can be inherited the same way as classe...Structures can be inherited the same way as classes.<BR/>Difference between structures and classes:<BR/>1)Structures have all parameters as public by default but classes have the members private by default.<BR/>2)Structures are allocated memory at stack and objects are allocated memory at heap.<BR/>But if the structure is allocated memory dynamically, then again the memory is allocated at heap<BRDivyahttp://www.blogger.com/profile/10305499374830744245noreply@blogger.comtag:blogger.com,1999:blog-8821078224593983074.post-34219463308239953662007-01-10T12:03:00.000-05:002007-01-10T12:03:00.000-05:00The struct type is good for representing lightweig...The struct type is good for representing lightweight objects such as Point, Rectangle, and Color. Although it is possible to represent a point as a class, but a struct is more efficient in some scenarios. i.e. if you declare an array of 3000 Point objects, we will allocate additional memory for referencing each object. In this case, the struct is less expensive.Veenu Thakurnoreply@blogger.com