How to Create a Class Property

W

Wayland

I'm programming in C# and I have a class diagram in which I want to display
properties for the class. How can I do this? I only see attributes and
operations.

Is there a way to denote that a property is read-only, i.e. only contains a
get method?

Also, constructors are not labeled as such, only operations with no return
method.

This is a sample class I want to document:

class 1
{
// attributes
private bool isInitialized = false;
private int count = 0;

// constructor
public class1(){}

// property
public bool IsInitialized
{
get{return isInitialized;}
set{isInitialized = value;}
}

// read only property
public int Count
{
get{return count;}
}

// operation
public void IncrementCount()
{
count++;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top