In this article, you will see how to actualize a simple basic in C# and how to use it in a applicant program. For an archetype I will use an Arithmetic component, which does addition. The term component in the software industry is often used to refer to a reusable object that exposes one or more interfaces to clients in a standardized way. A basic may be implemented as a individual class, or as a set of classes; the primary requirement is that the basic public interface be well-defined. To create properties in C# you use the get and set accessors. The get accessor is used for getting (reading). The set accessor for setting (writing) the property.
using System;
namespace CompCS
{
public class csAddComp1
{
private int i=0,j=0;
public int varI
{
get { return i; } //this is property get for varI
set { i=value; } //this is property set for varI
}
public int varJ
{
get { return j; } // this is property get for varJ
set { j=value; } // this is property set for varJ
}
public int Sum()
{
return i+j; //this returns the sum of two variables
}
} //end of class
} //end of namespace
0 comments:
Post a Comment