Solved

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

Posted on 2012-04-04
1
255 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

772 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