Solved

What is Best Method to Apply Business Rules to Properties in C# Class

Posted on 2012-04-04
1
246 Views
Last Modified: 2012-04-09
I am attempting to write a new class that will be used by various users and other classes to display and save information. What would be the best way for these properties, which can be entered, calculated, and displayed to be accessed within a centralized C# class with rules on a specific business? I was looking for the easiest method to access them as other developers will be using the same code in the future. Any help would be greatly appreciated
0
Comment
Question by:thenthorn1010
1 Comment
 
LVL 1

Accepted Solution

by:
IceBird26 earned 500 total points
ID: 37806382
You could use a static class that contains properties and methods which could be used without creating an instance of that class. An example:

public static class Global
{
    public const double Pie = 3.14159265;                           //Constant
    public static string ConnectionString = string.Empty;      //Property

    public static int AddNumbers(int x, int y)
    {
        return x + y;
    }
}


To use:

      static void Main()
      {
          int radius = 2;
          double circleArea = Global.Pie * radius * radius;

          Global.ConnectionString = "userid=jsmith; pwd=12345; server=Blueberry";
          MakeSQLConnection(Global.ConnectionString);

          int myTotal = Global.AddNumbers(5, 10);  
      }
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now