Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

9. Other Framework Types > Creating Structures

Creating Structures

image

Time to get our hands dirty and create a structure. We’ll stub it out in the Class Designer and then complete the code in the Editor.

0 Create a new Class Library project. You can close the Class1.cs file that Visual Studio creates by default; we won’t be using it.

1 Add a new Class Diagram to the project. From the Toolbox, drag a Struct onto the diagram pane. The Designer will display the New Struct dialog. It’s almost identical to the New Class dialog we worked with in the last chapter. Change the name to FirstStructure and press the OK button.

image

How’d You Do?

image

image

2 The Class Details pane for a structure looks just as it did when you added a class, too. (Visual Studio doesn’t even change the name!) That’s because the main difference between a class and a structure when you’re creating the definition is that a structure always inherits directly from System.ValueType.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint