10 January 2013

Class Diagram in C#.Net

                        Class Diagrams are newly added in Visual Studio 2005 edition. They provide designers, architects and developers a graphical interface to manipulate methods, properties, fields, events for data structures like classes, interfaces, structure etc.
Let us now explore all the features of Class designer.
Creating Classes using Class Diagrams
Create New Project in Visual Studio 2008 called “Class Diagram”.
Add Class Diagram’s File in your Project. It is shown below.

Class Diagram name is Called “Maths.cd”.

Right Click on the Screen .Context menu will display

Click “Class” Menu in the Screen.

Add Class name “Calculation”.
You can also choose Access of Class using Access Drop down box.
Right Click on your Class File in the Class Diagram.
Click “Add” Menu
Click “Property” Menu if you want.  i.e:  first Name, secondName.

Note: Same Procedure for Method, struct, Field, Event.

Here, I create an Add Method for this Program.

Add Parameter for Method:

        Go to Class Details window.

        Add your parameter for your method.

        Two parameters assigned for Add method (firstValue, secondValue).

       Go to method property in the classdiagram file.

       Change the Value of false to true of the static property of the method.

       See below screen

 Go to your Calculation.cs file and add this code in the Add Method

   returnfirstValue + secondValue;
Copy and paste this code in your form_load Event
          int result = Calculation.Add(50,50);
 Thanks for reading this article. 

Today's Quoto:
        Life is like riding a bicycle. To keep your balance, you must keep moving!

No comments: