Solved

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

Posted on 2012-04-04
1
278 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

630 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