h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Class Diagram in C#.Net



Introduction:
                        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

   return firstValue + secondValue;
Copy and paste this code in your form_load Event
          int result = Calculation.Add(50,50);
     MessageBox.Show(result.ToString());
Result:
     100.
 Thanks for reading this article. 

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