|
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..
|
|
|
|
|
If you feel it is going to be interesting for people, and if you've had some interesting solution, then why not, go ahead
Regards,
Lev
|
|
|
|
|
|
hi,
cmd.CommandType = CommandType.StoredProcedure;
string filldate = GridView2.Rows[e.RowIndex].Cells[2].Text;
string freedate = GridView2.Rows[e.RowIndex].Cells[3].Text;
cmd.Parameters.AddWithValue("@filleddate",filldate);
cmd.Parameters.AddWithValue("@freedate", freedate);
cmd.Parameters.AddWithValue("@nameofcustomer", GridView2.Rows[e.RowIndex].Cells[6].Text);
try
{
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
}
and stored procedure is:
Insert into PresidentialSuite(DateWhenFilled,DateWhenFree,NameOfCustomer)
values (@filleddate,@freedate,@nameofcustomer);
SET @filleddate = Convert(datetime,@filleddate);
SET @freedate = Convert(datetime,@freedate);
Iam not converting any nvarchar to datetime. why iam getting this error.
i tried number of ways of converting string to datetime in my C# code, but failed. so i used stored procedure.
thanks in advance
|
|
|
|
|
I suspect your date format is not what is expected by sql server, usually because one is using mm/dd/yyyy and the other is using dd/mm/yyyy.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Hi,
thanks for reply,
due to those reasons i left the conversion to sqlserver, i used the 'convert' in stored procedure.
bec i tried almost all ways of converting in my C# code
|
|
|
|
|
suni_dotnet wrote: i tried number of ways of converting string to datetime in my C# code, but failed.
You tried DateTime.Parse(...) and it failed? Obviously the input needs to be validated before even getting to your database.
only two letters away from being an asset
|
|
|
|