C# 24-Hour Trainer by Rod Stephens

C# 24-Hour Trainer by Rod Stephens

Author:Rod Stephens
Language: eng
Format: epub, mobi, azw3, pdf
ISBN: 9781119065692
Published: 2015-11-02T00:00:00+00:00


Because the two value variables refer to different copies of the same data, changing one doesn't change the other. For example, if you execute the statement dan.Name = "Dan", then the value cindy.Name will still be Cindy.

The Structure Versus Class example program, which is available in this lesson's downloads, demonstrates this difference. This issue is quite important, so it will be worth your time to download the example and study it until you're sure you understand it.

So which should you use, a structure or a class? In many programs the difference doesn't matter much. As long as you are aware of the relevant differences, you can often use either.

Microsoft's “Classes and Structs (C# Programming Guide)” web page at msdn.microsoft.com/library/ms173109.aspx gives this advice:

In general, classes are used to model more complex behavior, or data that is intended to be modified after a class object is created. Structs are best suited for small data structures that contain primarily data that is not intended to be modified after the struct is created.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.