|
This has absolutely no relevance, but:
class UglyClass {
public UglyClass() {
if (true) {
DoThis();
DoThat();
}
if (true) DoSomethingElse();
}
}
class PrettyClass
{
public PrettyClass()
{
if (true)
{
DoThis();
DoThat();
}
if (true)
{
DoSomethingElse();
}
}
}
|
|
|
|
|
bobsugar222 wrote: This has absolutely no relevance
I agree. I would add, your way wastes more space.
Luc Pattyn
|
|
|
|
|
Easier to read and maintain though... on top of being prettier
|
|
|
|
|
Splitting things into separate lines does not add beauty.
class
UglyClass
{
public
UglyClass
()
{
if
(true)
{
DoThis
();
DoThat
();
}
if
(true)
DoSomethingElse
();
}
}
If you want the extra space, add the extra space. Then it's intentional and worth something.
class PrettyClass {
public PrettyClass() {
if (true) {
DoThis();
DoThat();
}
if (true) {
DoSomethingElse();
}
}
}
---
Year happy = new Year(2007);
|
|
|
|
|
Once more I agree
Luc Pattyn
|
|
|
|
|
|
Hi,
I have just finished an article on timers, I trust it may well solve your problem.
I expect it will appear on CP in a matter of days.
Luc Pattyn
|
|
|
|
|
|
Hi,
this dialog seems very good, but is there a way to make it run under .NET 1.1? Or in other words, what makes it only compatible for 2.0?
BR
Alexander
|
|
|
|
|
What dialog?
---
Year happy = new Year(2007);
|
|
|
|
|
Oops, I must have posted my question in the wrong forum, but perhaps someone here can also help me with that. I mean the OpenDialogEx:
http://www.codeproject.com/cs/miscctrl/OpenFileDialogEx.asp
(I clicked "New Message" on the bottom of that page, now I am confused (about this forum), and there might be a cross-post somewhere else here... )
|
|
|
|
|
I Want Last Version OutlockBarApp Simular Visual Studio.Net 2005
Thank you
Send (Dll File) ...
|
|
|
|
|
im actually trying to make a player that can stream audio over the network in real time using Microsoft DirectX particularly direct sound.can anyone help me out with this problem please..im a newbie when it comes to audio programming..please i really need help as soon as possible...
mei
|
|
|
|
|
//eraser is gif file from resources
Bitmap bmp = new Bitmap(global::InkRecognition.Properties.Resources.eraser);
bmp.SetResolution(128f,128);
System.Windows.Forms.Cursor cursor = new System.Windows.Forms.Cursor(bmp.GetHicon());
this.Cursor = cursor;
somehow SetResolution just don't work. anyone help please
thanks
|
|
|
|
|
What do you expect it to do ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi,
I have a WinForm that needs to run only if a registry entry exists. If not, I want the application to immediately exit.
I don't believe you can call Application.Exit until after initialization of the form is complete.
Is there a workaround or better solution to achieve my needs?
Glen Harvy
|
|
|
|
|
Why not do it in Form's Constructor.... It's run b4 Initialization. You can call dispose from there.
Or even better you can use a static constructor try to set a static boolean variable and check it's value b4 instantiating...
Any Static Construct is the first thing which is run After class loading.
|
|
|
|
|
Syed Muhammad Kamran wrote: Or even better you can use a static constructor try to set a static boolean variable and check it's value b4 instantiating...
Any Static Construct is the first thing which is run After class loading.
Thanks for your assistance ... I have a rough idea of what you suggest but would appreciate your elaborating a bit.
This is what I have now:
<br />
<br />
namespace blahblah<br />
{<br />
public partial class MainForm : Form<br />
{<br />
public MainForm()<br />
{<br />
bool startupCheckValue = true;<br />
startupCheckValue = startupCheck();<br />
if (!startupCheckValue)<br />
{<br />
Dispose();<br />
this.Close();<br />
Application.Exit();
}<br />
etc etc etc<br />
<br />
private bool startupCheck()<br />
{<br />
[code works fine]<br />
}<br />
<br />
<br />
How do I go about implementing what you suggest.
Thanks in advance.
Glen Harvy
|
|
|
|
|
namespace blahblah
{
public partial class MainForm : Form
{
static bool startUpCheckValue = false;
static MainForm (){
startupCheckValue = StartupCheck();
}
public MainForm()
{
if (!startupCheckValue)
{
Dispose();
this.Close();
Application.Exit(); // exitProgram();
}
etc etc etc
private static bool startupCheck()
{
// make sure database file exists
//
[code works fine]
}
|
|
|
|
|
Thanks for that - I have since done some research and certainly understand constructors and specifically static constructors and methods a little better Frankly, I agree your suggestion should work - at least in theory.
Unfortunately I still can't get the program to exit. I made the changes you suggested without success and then as an extreme test changed it to the following:
<br />
public partial class MainForm : Form<br />
{<br />
static MainForm()<br />
{<br />
Application.Exit();<br />
}<br />
public MainForm()<br />
{<br />
<br />
[etc etc]<br />
I'll keep delving into this and welcome any other suggestions.
Glen Harvy
|
|
|
|
|
Application.Exit will nit work inside the constructor, because Application.Run wasn't executed yet. If you look at the static Main method of your application it looks similar to this:
static void Main()
{
Applivation.Run(new MainForm());
}
So what happens, is that an instance of the MainForm class is created (calling your constructor) and afterwards passed to the Application.Run method. That's why Application.Exit does not work inside the constructor.
It would probably be the best to assign the instance of MainForm to a variable and only call Application.Run, if your MainForm could be properly initialized:
static void Main()
{
MainForm form = new MainForm();
if (something)
{
Applivation.Run(form);
}
else
{
Show some kind of error message
}
}
"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
|
|
|
|
|
Thanks very much - I've learn't heaps tonight.
Glen Harvy
|
|
|
|
|
My pleasure
"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
|
|
|
|
|
i want to make my event in win form
using c#.i have created it but
the problem is that the event is not firing.
so i need your help.
i created these events by taking help of
vb.net program.
ashu
|
|
|
|
|
What event? and give us some code
|
|
|
|