Click here to Skip to main content
16,013,322 members
Home / Discussions / C#
   

C#

 
GeneralRe: SQLParameters Pin
Ista22-Jul-03 9:10
Ista22-Jul-03 9:10 
GeneralCell colors in DataGrid Pin
Anonymous21-Jul-03 13:46
Anonymous21-Jul-03 13:46 
GeneralRe: Cell colors in DataGrid Pin
Mazdak21-Jul-03 20:08
Mazdak21-Jul-03 20:08 
GeneralRe: Cell colors in DataGrid Pin
albean22-Jul-03 17:20
albean22-Jul-03 17:20 
GeneralUmm.. Stupid Question Pin
Nick Parker21-Jul-03 12:29
protectorNick Parker21-Jul-03 12:29 
GeneralRe: Umm.. Stupid Question Pin
J. Dunlap21-Jul-03 12:51
J. Dunlap21-Jul-03 12:51 
GeneralRe: Umm.. Stupid Question Pin
Nick Parker21-Jul-03 17:16
protectorNick Parker21-Jul-03 17:16 
GeneralRe: Umm.. Stupid Question Pin
James T. Johnson21-Jul-03 15:46
James T. Johnson21-Jul-03 15:46 
Nick Parker wrote:
The idea would allow me to pass the one instance all throughout the application regardless of the form it is on.

If you will only have that one instance through-out the entire life of the application, then you would probably benefit from using a singleton.

public sealed class A
{
  private A()
  {
    // construct
  }
 
  private static object lockObject = new object();
  private static A instance;
 
  public A Instance
  {
    get 
    {
      if( instance == null )
      {
        lock( lockObject )
        {
          if( instance == null )
          {
            instance = new A();
          }
        }
      }
 
      return instance;
    }
  }
}
This ensures that only one instance is ever created and makes it so you don't have to be passing that instance all over the place.

James

"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him

GeneralRe: Umm.. Stupid Question Pin
Rocky Moore21-Jul-03 16:01
Rocky Moore21-Jul-03 16:01 
GeneralRe: Umm.. Stupid Question Pin
James T. Johnson21-Jul-03 16:12
James T. Johnson21-Jul-03 16:12 
GeneralRe: Umm.. Stupid Question Pin
Rocky Moore21-Jul-03 17:25
Rocky Moore21-Jul-03 17:25 
GeneralRe: Umm.. Stupid Question Pin
Nick Parker21-Jul-03 18:01
protectorNick Parker21-Jul-03 18:01 
GeneralRe: Umm.. Stupid Question Pin
Rocky Moore21-Jul-03 21:48
Rocky Moore21-Jul-03 21:48 
GeneralRe: Umm.. Stupid Question Pin
Nick Parker21-Jul-03 17:14
protectorNick Parker21-Jul-03 17:14 
GeneralRe: Umm.. Stupid Question Pin
J. Dunlap21-Jul-03 17:44
J. Dunlap21-Jul-03 17:44 
GeneralRe: Umm.. Stupid Question Pin
Kannan Kalyanaraman21-Jul-03 19:32
Kannan Kalyanaraman21-Jul-03 19:32 
GeneralRe: Umm.. Stupid Question Pin
James T. Johnson21-Jul-03 19:38
James T. Johnson21-Jul-03 19:38 
GeneralRe: Umm.. Stupid Question Pin
Kannan Kalyanaraman21-Jul-03 20:08
Kannan Kalyanaraman21-Jul-03 20:08 
GeneralPrinting a DataGrid Pin
Mike Osbahr21-Jul-03 11:42
Mike Osbahr21-Jul-03 11:42 
GeneralRecord Types Pin
dbetting21-Jul-03 11:28
dbetting21-Jul-03 11:28 
GeneralRe: Record Types Pin
David Stone21-Jul-03 13:44
sitebuilderDavid Stone21-Jul-03 13:44 
GeneralRe: Record Types Pin
Ista21-Jul-03 17:10
Ista21-Jul-03 17:10 
GeneralRe: Record Types Pin
dbetting22-Jul-03 2:47
dbetting22-Jul-03 2:47 
GeneralEncapsulating Database in custom class Pin
sandman_max21-Jul-03 11:15
sandman_max21-Jul-03 11:15 
GeneralRe: Encapsulating Database in custom class Pin
Rocky Moore21-Jul-03 17:10
Rocky Moore21-Jul-03 17:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.