Click here to Skip to main content
15,892,161 members
Home / Discussions / C#
   

C#

 
AnswerRe: Single intance Pin
Christian Graus22-Nov-06 23:57
protectorChristian Graus22-Nov-06 23:57 
GeneralRe: Single intance Pin
kinnuP23-Nov-06 0:01
kinnuP23-Nov-06 0:01 
GeneralRe: Single intance Pin
Colin Angus Mackay23-Nov-06 0:19
Colin Angus Mackay23-Nov-06 0:19 
GeneralRe: Single intance Pin
Prakash Nadar23-Nov-06 2:04
Prakash Nadar23-Nov-06 2:04 
GeneralRe: Single intance Pin
Colin Angus Mackay23-Nov-06 6:21
Colin Angus Mackay23-Nov-06 6:21 
JokeRe: Single intance Pin
Nader Elshehabi23-Nov-06 8:08
Nader Elshehabi23-Nov-06 8:08 
GeneralRe: Single intance Pin
kinnuP23-Nov-06 0:40
kinnuP23-Nov-06 0:40 
AnswerRe: Single intance Pin
Schmullus23-Nov-06 0:17
Schmullus23-Nov-06 0:17 
Hi,

my you use an static variable within the class
that counts the instances.

namespace ConsoleApplication1<br />
{<br />
    class TestClass<br />
    {<br />
        // static variable<br />
        public static int instanceCount = 0;<br />
<br />
        // Constructor<br />
        public TestClass()<br />
        {<br />
            instanceCount++;<br />
        }<br />
        // Some code<br />
        // ...<br />
    }<br />
<br />
    class Program<br />
    {<br />
        static void Main(string[] args)<br />
        {<br />
            TestClass myTestClass1 = new TestClass();<br />
            TestClass myTestClass2 = new TestClass();<br />
            Console.WriteLine(TestClass.instanceCount);<br />
            Console.ReadLine();<br />
        }<br />
    }<br />
}<br />


You can use the variable 'instanceCount' to restrict the instance generation.

Is it that what you're looking for?

Regards

Erik
GeneralRe: Single intance Pin
Colin Angus Mackay23-Nov-06 0:21
Colin Angus Mackay23-Nov-06 0:21 
GeneralRe: Single intance Pin
Prakash Nadar23-Nov-06 2:05
Prakash Nadar23-Nov-06 2:05 
AnswerRe: Single intance Pin
Colin Angus Mackay23-Nov-06 0:21
Colin Angus Mackay23-Nov-06 0:21 
GeneralRe: Single intance Pin
kinnuP23-Nov-06 0:31
kinnuP23-Nov-06 0:31 
QuestionProblem with Invisible Unbound CheckBox DatagridView field. Pin
hdv21222-Nov-06 23:50
hdv21222-Nov-06 23:50 
QuestionChange ToolTip-Font Pin
Schmullus22-Nov-06 23:43
Schmullus22-Nov-06 23:43 
Questioncontrol image Pin
sachin4140622-Nov-06 23:38
sachin4140622-Nov-06 23:38 
AnswerRe: control image Pin
Christian Graus22-Nov-06 23:56
protectorChristian Graus22-Nov-06 23:56 
QuestionRemove ToolTip from a special control Pin
C-Scharbe22-Nov-06 22:18
C-Scharbe22-Nov-06 22:18 
AnswerRe: Remove ToolTip from a special control Pin
Schmullus22-Nov-06 23:09
Schmullus22-Nov-06 23:09 
GeneralRe: Remove ToolTip from a special control Pin
Bhupi Bhai22-Nov-06 23:12
Bhupi Bhai22-Nov-06 23:12 
GeneralRe: Remove ToolTip from a special control Pin
C-Scharbe22-Nov-06 23:17
C-Scharbe22-Nov-06 23:17 
AnswerRe: Remove ToolTip from a special control Pin
rah_sin22-Nov-06 23:17
professionalrah_sin22-Nov-06 23:17 
AnswerRe: Remove ToolTip from a special control Pin
C-Scharbe23-Nov-06 0:14
C-Scharbe23-Nov-06 0:14 
AnswerRe: Remove ToolTip from a special control Pin
Psytechnic12-Jan-10 2:08
Psytechnic12-Jan-10 2:08 
Questionopen a nodepad.txt in c# program Pin
faladrim22-Nov-06 22:08
faladrim22-Nov-06 22:08 
AnswerRe: open a nodepad.txt in c# program Pin
rah_sin22-Nov-06 22:38
professionalrah_sin22-Nov-06 22:38 

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.