|
You need to understand the algorithm to store data in a binary tree. It's not hard. Once you understand this, you can write the code yourself.
|
|
|
|
|
Hi,
I'm writing an application in which I'm currently using Console.Writeline() calls to output the various stages. This helps me to develop and debug as I go. However, the time will come when I want to remove all such calls. Can anyone suggest some advice, an article (I have searched on CP) or other source which will tell me how to use debug statements in code which I can then switch off for release.
I was thinking of a logging class - in debug mode it would write to the console but in release mode it would write certain information to a file. The Console.Writeline() methods allows me to do the following:
Console.Writeline("Val1 {0}, Val2 {2}", val1, val2);
How could I write my own function which would accept an unknown number of parameters like this? I would like my function to pass the parameters directly to Console.Writeline() or to a file depending on a flag.
Thanks for any help offered
|
|
|
|
|
Wrap them in #if DEBUG blocks.
#if DEBUG
Console.WriteLine("Debugging");
#endif
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)
|
|
|
|
|
or
System.Diagnostics.Debug.Write with appropriate listeners.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Member 5646867 wrote: However, the time will come when I want to remove all such calls.
Replace Console.Writeline with Debug.Writeline ...
If you do a Release build, the calls to the Debug.Writeline should not be included in the executable.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
modified on Tuesday, November 18, 2008 2:38 PM
|
|
|
|
|
I don't know about that. I would think the calls to Debug.WriteLine , or anything else in the Debug class, would be left out though. Console, I think, stays around, even though it's a Windows Forms app.
|
|
|
|
|
Yup. It is the Debug class. Got my wires crossed there for a moment
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Thanks for all your answers - I'll look into each of the suggestions
|
|
|
|
|
Hi,
I am trying to write a code that gets all the files in a folder and returns the name of the file that has the most recent "write" date.
i have wrote this function that gets "path" and should return fileName string.
string[] fileNames = Directory.GetFiles(filePath); // get file names in array
string[] fileDatesList = fileNames; // create fileDateList and initialze(not relevant with what
for (int i = 0; i < fileNames.Length; i++)
{
fileDatesList[i] = Directory.GetLastWriteTime(fileNames[i]).ToString();
}
//TODO write the return(
my problem is with this line:
fileDatesList[i] = Directory.GetLastWriteTime(fileNames[i]).ToString();
lets say i have 3 files in a folder:
abc00, abc01, abc02.
fileNames string array gets all 3 names and stores them.
when i get to the fileDatesList in the for loop, all the entities in
fileNames array are CHANGED with the Date of the file...
example:
before for loop:
fileNames=[abc00,abc01,abc02]
fileDatesList=[abc00,abc01,abc02]
step i=0:
fileNames=[18/11/2008 4:25PM,abc01,abc02]
fileDatesList=[18/11/2008 4:25PM,abc01,abc02]
and so on untill both have only date and time...
i don't understand why it does that why it changes fileNames while changing fileDatesList... although i am not assigning fileDatesList to fileNames in anywhere out of the getLastWriteTime...
thanks a lot!
May The Force Be With You...
|
|
|
|
|
string[] fileDatesList = new string[fileNames.Length];
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
thanks a lot
that is a new bee error
May The Force Be With You...
|
|
|
|
|
beriho wrote: string[] fileDatesList = fileNames; // create fileDateList and initialze(not relevant with what
This is your problem. You think that declaring a variable that is a reference to a string array does also create an array of strings, but it doesn't. You end up with two references to the same array of strings. Anything that you do to the array through one of the references is what you see when you access the array through the other reference.
You have to create a new array, so that you have two separate arrays:
string[] fileDatesList = new string[fileNames.Length];
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
thank you!
May The Force Be With You...
|
|
|
|
|
I learn best by doing. I can read a book or sit in a class, but it's when I have to actually sit down and type the code in that I learn best.
So can anyone point me to a few websites (or projects/articles HERE) that might be geared toward this type of learning? You know, some C# project from start to finish? Maybe some dif't levels, starting at simple and working up to harder projects?
I have a programming background and experience w/ Microsoft products and even some .NET. It's just hard to be motivated on this project at the moment and I think this is what I need to kickstart it.
Thanks, all.
P.S. My latest project is a simple .NET web interface to:
allow user input
to a SQL Server backend and
generate some reports,
so something along those lines would be IDEAL
Edit: not really looking for beginner "tutorials" such as Quick C#... I have books that show syntax, and I already have a feel for the language... I need to figure out how to put it all together.
|
|
|
|
|
Pick something that will give you a sense of accomplishment when it's done. This will motivate you to finish it.
|
|
|
|
|
I lost interest in your message when I saw this:
Dougmeister wrote: Maybe some dif't levels
You abbreviated textspeak with an apostrophe instead of typing out the entire word "different". Why should we take the time to help you if you're not willing to take the time to communicate clearly?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thanks for taking the time to tell me that.
dif't
dif't
dif't
|
|
|
|
|
Give it a rest John.
Everyone knows what he meant
|
|
|
|
|
Yes evr1 new bt i's h'dr to rd de tx wen u hv to d-cipr it 1st.
Despite everything, the person most likely to be fooling you next is yourself.
modified on Tuesday, November 18, 2008 10:26 AM
|
|
|
|
|
I never rest. I knew what he meant (obviously), but I stand by my assertion that I am apathetic to his question due his lack of respect for those of us with a proper education.
Oh yeah, and who the hell are you, Member 5646867? If you're not willing to use a proper user ID, you haven't earned the right to call me by my first name.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Don't worry about who I am. I'm just another person on the Internet who comes here for help and advice.
If you don't want to answer his question, then that's fine but there was nothing constructive in what you posted. This is despite the fact that you can be a very positive contributor here and I've always had respect for your technical knowledge and experience.
FWIW (you don't mind acronyms do you?), text-speak irritates me too and I don't blame you for not wishing to answer his question. However, it just seems like you enjoy being offended a little too much.
|
|
|
|
|
1) Define "proper education"
2) Who did it, anyway?
|
|
|
|
|
|
hi,
I am developing an application in which i need to implement screen saver ,when ever there is no event takes place in the form like mouse move or key press the screen saver will automatically come after some time.
Thank's
jugal
|
|
|
|
|
And the question is?
Regards
Sebastian
|
|
|
|