|
If you define a member variable in your class, then you can test whether the member is null or not to decide whether to show the form:-
class MyClass
{
...
MyForm m_frm;
public void OnButton1Click(object sender, EventArgs e)
{
if (m_frm == null)
{
m_frm = new MyForm();
m_form.Show();
}
}
}
The problem with that is that if the user closes the form, they'll not be able to reopen it. To do that you'd need to handle the form's Closing event, and set the m_frm reference to null.
|
|
|
|
|
Does anybody how to generate numbers according to a gaussian (or Normal) distribution?
I read something about RandomNumberGenerator Class but I don´t find anything about gaussian distributions
Thanks a lot
Kurtz
|
|
|
|
|
I'v published an article on .NET random number generators and distributions[^] here CP. Amongst others it provides an implementation of a normal distribution. Hope it will help you
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Does anybody how to generate numbers according to a gaussian (or Normal) distribution?
I read something about RandomNumberGenerator Class but I don´t find anything about gaussian distributions
Thanks a lot
Kurtz
|
|
|
|
|
|
Hi,
All my auto-generated classes are Public by default. Is it possible to make some of them internal by default?
If I edit the code manually it will get auto-generated when I change the dataset, which I don't want to happen.
Any help much appreciated.
Andrew
|
|
|
|
|
hi,
i hv to use the rownumber(rowindex) to fetch a row from database.i was trying to use LIMIT keyword for this.but it didn't work.(i.e i th row from database).
please help me .
iam using VISUAL STUDIO 2005.
|
|
|
|
|
Hi,
I stored connection string in web.config file. and I call it in c# program as follows.
SqlConnection cn;
sConn = ConfigurationSettings.AppSettings("dbconnection");
cn = new SqlConnection(sConn);
cn.Open();
then it is giving a error message
'System.Configuration.ConfigurationSettings.AppSettings' denotes a 'property' where a 'method' was expected
please I am a new programmer. can anyone help me?
Thank you.
|
|
|
|
|
hi ,
u have to call the ConfigurationSettings.AppSettings["dbconnection"];
place u r asp.net questions in asp.net form not in C# u will get quick responce
-- modified at 6:02 Thursday 23rd November, 2006
P.gurukiran
|
|
|
|
|
kinnuP wrote: u
kinnuP wrote: r
Please write properly - TXTSPK is difficult to understand and you are not constrained to 160 characters.
kinnuP wrote: place u r asp.net questions in asp.net form not in C#
This question was NOT specific to ASP.NET. The answer, which YOU gave, was a correction of C# syntax - Other than a reference to web.config (and it could just have easily been app.config, because the C# code to access that is no different), it had nothing to do with ASP.NET.
|
|
|
|
|
|
I tried it again with App.config file. but same error is comming. pls can you help me?
Thanks
|
|
|
|
|
Probably not an error, but a warning. The appsettings is obsolete since VS.NET 2005.
Create a reference to System.Configuration and use :
System.Configuration.ConfigurationManager.AppSettings["SettingName"];
That should do the trick
- - - --[ i love it when a plan comes together ]-- - - -
|
|
|
|
|
I tried that again,
then it is an another error called:
The type or namespace name 'ConfigurationManager' does not exist in the class or namespace 'System.Configuration' (are you missing an assembly reference?)
I am a beginner for c# can you help me?
thank you
|
|
|
|
|
hi all,
i want to know how to restrict the class not to instaciate more than once in C# help me in this plse...
P.gurukiran
|
|
|
|
|
A private constructor and a create method. A static boolean flag that starts as false, is set true by the Create method, and returns null once that flag is true.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
thank u Christian Graus , but i need any key words are available for it to restrict it is more help full
P.gurukiran
|
|
|
|
|
Christian Graus wrote: A private constructor and a create method. A static boolean flag that starts as false, is set true by the Create method, and returns null once that flag is true.
Ummmm.... I'm not sure how that describes a singleton. I've never used a Boolean flag in any of my singletons. They look a bit like this:
public SingletonClass
{
private static SingletonClass onlyInstance;
private SingletonClass()
{
}
public SingletonClass Instance
{
get
{
if (onlyInstance == null)
onlyInstance = new SingletonClass();
return onlyInstance;
}
}
}
|
|
|
|
|
where is the removed declared?
and how is onlyInstance initialised?
-Prakash
|
|
|
|
|
Mr.Prakash wrote: where is the removed declared?
and how is onlyInstance initialised?
The curious thing is that I thought I'd messed up my post, but when I went to modify it the code displays correctly in the edit window. "removed" should read "onlyInstance" and I have absolutely no idea why it says removed.
|
|
|
|
|
Looks like Bob is teasing you a little!!
Regards
|
|
|
|
|
hi Christian Graus, i am trying above code i am not able restrict the class please can u provide smple code it will help me lot
P.gurukiran
|
|
|
|
|
Hi,
my you use an static variable within the class
that counts the instances.
namespace ConsoleApplication1<br />
{<br />
class TestClass<br />
{<br />
public static int instanceCount = 0;<br />
<br />
public TestClass()<br />
{<br />
instanceCount++;<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
|
|
|
|
|
I think the original poster was describing a singleton class.
|
|
|
|
|
your code sample can not be used to retrict the number of instances, it only helps in couting the instances.
As long as you keep the constructor public, it will be difficult (maybe impossible) to create a singleton class.
-Prakash
|
|
|
|