|
He could also use the reverse-singleton pattern?
I are troll
|
|
|
|
|
|
Int control= count;
Whiskey:
if (control== 0)
goto Foxtrot;
else
goto Tango;
Tango:
MyMethodCall();
control--;
goto Whiskey;
FoxTrot:
Edit: Improved code.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
modified on Thursday, January 8, 2009 3:38 PM
|
|
|
|
|
I see everyone's using goto after yesterday's discussion!
int control = 5;
while (control > 0)
{
MyMethodCall();
control--;
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
That is such a bad use of goto...
for (int i=0; i<6; i++)
MyMethodCall();
|
|
|
|
|
Let's hope count is positive now.
|
|
|
|
|
Hi,
labels too deserve meaningful names, they add to the readability of the source code; so I would suggest:
uint control= count;
WhileThereMayBeMore:
if (control== 0)
goto FinallyWhenDone;
else
goto ThisIsWhereWeCallTheMethod;
ThisIsWhereWeCallTheMethod:
MyMethodCall();
control--;
goto WhileThereMayBeMore;
FinallyWhenDone:
BTW: why is it all examples seem to use PascalCase labels, they are local after all?
(e.g. read MSDN on the goto keyword)
|
|
|
|
|
My labels do have meaningful names when looked at collectively. Perhaps I was too subtle.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Sure they do, however you could combine individual and collective meaning, yielding the best of both worlds.
|
|
|
|
|
Hmm, I'm sure you could fit some XML in there, keep the counter in a database table, or even create a custom CountNotYetAchieved Exception class. I'd even settle for a string counter and Int32.Parse it on each iteration. Come on guys, integer counters are soooo yesterday! Here's my real version:
while(count-- > 0) MyMethod();
One other thing is the else technically is unnecessary in the Whiskey label...
Last, you could spice it up with if(!(control != 0)) , that would make it really nice!
Keep It Simple Stupid! (KISS)
|
|
|
|
|
Hi, is it possible to make an application (it can be a web application or desktop, not much important) that to display a live video from a webcam? It will be both video and and sound.
I searched on it but, i couldnt find how to do it both video and sound together.
If u could help me, thanks for your answers from now.
|
|
|
|
|
|
I am looking at the system.windows.media.colors class and the system.windows.media.color struct
I assume there is some kind of collection in the colors class of the color struct, so when you type colors. it gives a drop down list of the color structs that are contained within the colors class.
I need to replicate the same kind of functionality, but am unsure on how to go about building the colors class to give the drop down showing named instances of the structs.
Any help most welcome
Mark
|
|
|
|
|
what about something like:
foreach(Color c in Colors)
{
ComboBox1.Items.Add(c.ToString());
}
|
|
|
|
|
I am trying to understand the underlying code of the colors class, so i can replcate it for a differnt use. It has the functionality i need, but i am going to use it for something other than colors
|
|
|
|
|
ahh then you may want to use an 'enum'
public enum Values{
One = 1
Two = 2
}
then acces like
Values.One
or Values.Two
modified on Thursday, January 8, 2009 12:28 PM
|
|
|
|
|
thats the kind of functionality i need, but it need to display structs, which is where i start getting stuck
|
|
|
|
|
You could examine the source of the Color struct.
A very simple implementation (loads missed out!) using the proper spelling...
public struct Colour
{
private byte m_R;
private byte m_G;
private byte m_B;
public Colour(byte r, byte g, byte b)
{
m_R = r;
m_G = g;
m_B = b;
}
public byte R { get { return m_R; } }
public byte G { get { return m_G; } }
public byte B { get { return m_B; } }
public static Colour White
{
get { return new Colour(255, 255, 255); }
}
public static Colour Black
{
get { return new Colour(0, 0, 0); }
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
EDIT - Scratch that, i have worked out how the above sorts everything out for me
THANKS
I agree about the spelling
|
|
|
|
|
yeah thats what i meant to write lol
|
|
|
|
|
Can you recommend some free reliable source control software? Thanks
|
|
|
|
|
|
You may get answers here - but a better place may be in the lounge (if you do - link to this thread so you don't get flamed for cross posting!). If you do a search there first you'll see that it's been discussed many times and will probably save you the trouble of posting.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I prefer Subversion[^], but you may want to use a different version system based on your needs.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I've been working on a so called 'TextControl' which is a label, but without the padding that is added in 'normal' labels.
I think all majour features have been implemented, so I was wondering if I should create an article about that..
|
|
|
|