Picking Up C# or How I typed my fingers to the bone
-
I'm an old guy. I've gone up the technical ranks to run a couple of significant software development groups; suffered the crash and now code for a living. I haven't coded in every programing language known, but then, I've got quite a few nothes on my pocket protector. I love C# but I don't think I've typed so much since the days of 'Big 8' COBOL. I get a chuckle on how much I have to type to get something so small done. I thought I'd seen everything when I found that a \n\r was replaced by an 'Environment.Linefeed'. But I really had to grin when I googled to find that to get my application path I needed to enter: string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); It works but I think I've only got another C# project before I'll need to replace my keyboard. I think we need a contest on what is the longest statement possible in c# to retrieve a smiple result. There are 8 dots between the = sign and the ; in the above snippet. :-D:-D:-D:-D
-
I'm an old guy. I've gone up the technical ranks to run a couple of significant software development groups; suffered the crash and now code for a living. I haven't coded in every programing language known, but then, I've got quite a few nothes on my pocket protector. I love C# but I don't think I've typed so much since the days of 'Big 8' COBOL. I get a chuckle on how much I have to type to get something so small done. I thought I'd seen everything when I found that a \n\r was replaced by an 'Environment.Linefeed'. But I really had to grin when I googled to find that to get my application path I needed to enter: string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); It works but I think I've only got another C# project before I'll need to replace my keyboard. I think we need a contest on what is the longest statement possible in c# to retrieve a smiple result. There are 8 dots between the = sign and the ; in the above snippet. :-D:-D:-D:-D
well, \r\n still works fine I use it all the time, and you might try to look up
using
in MSDN :rolleyes: - Anders Money talks, but all mine ever says is "Goodbye!" ShotKeeper, my Photo Album / Organizer Application[^]
My Photos[^] -
well, \r\n still works fine I use it all the time, and you might try to look up
using
in MSDN :rolleyes: - Anders Money talks, but all mine ever says is "Goodbye!" ShotKeeper, my Photo Album / Organizer Application[^]
My Photos[^] -
I'm an old guy. I've gone up the technical ranks to run a couple of significant software development groups; suffered the crash and now code for a living. I haven't coded in every programing language known, but then, I've got quite a few nothes on my pocket protector. I love C# but I don't think I've typed so much since the days of 'Big 8' COBOL. I get a chuckle on how much I have to type to get something so small done. I thought I'd seen everything when I found that a \n\r was replaced by an 'Environment.Linefeed'. But I really had to grin when I googled to find that to get my application path I needed to enter: string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); It works but I think I've only got another C# project before I'll need to replace my keyboard. I think we need a contest on what is the longest statement possible in c# to retrieve a smiple result. There are 8 dots between the = sign and the ; in the above snippet. :-D:-D:-D:-D
Most Z80 instructions were 2~4 letters (JP, LD, CALL, BCD, JNZ, JZ). All the 16-bit registers were two letters (AF, BC, DE, HL, IX, IY), but could be used as two 8-bit registers with only one letter. So, the following line was a valid Z80 instruction:
LD B,D
In C#, this would be the following:
byte B;
byte D;
B = D;I don't know why, but I do prefer working in C# than in Z80, even though I type more. And, maybe, Intelissense can help you :-D Yes, even I am blogging now!
-
Most Z80 instructions were 2~4 letters (JP, LD, CALL, BCD, JNZ, JZ). All the 16-bit registers were two letters (AF, BC, DE, HL, IX, IY), but could be used as two 8-bit registers with only one letter. So, the following line was a valid Z80 instruction:
LD B,D
In C#, this would be the following:
byte B;
byte D;
B = D;I don't know why, but I do prefer working in C# than in Z80, even though I type more. And, maybe, Intelissense can help you :-D Yes, even I am blogging now!
-
I'm an old guy. I've gone up the technical ranks to run a couple of significant software development groups; suffered the crash and now code for a living. I haven't coded in every programing language known, but then, I've got quite a few nothes on my pocket protector. I love C# but I don't think I've typed so much since the days of 'Big 8' COBOL. I get a chuckle on how much I have to type to get something so small done. I thought I'd seen everything when I found that a \n\r was replaced by an 'Environment.Linefeed'. But I really had to grin when I googled to find that to get my application path I needed to enter: string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); It works but I think I've only got another C# project before I'll need to replace my keyboard. I think we need a contest on what is the longest statement possible in c# to retrieve a smiple result. There are 8 dots between the = sign and the ; in the above snippet. :-D:-D:-D:-D
betterc wrote: when I googled to find that to get my application path I needed to enter Have you tried the property: Application.ExecutablePath Assuming you are working on a WinForm app.. Rocky <>< www.HintsAndTips.com www.MyQuickPoll.com - 2004 Election poll is #33 www.GotTheAnswerToSpam.com
-
I'm an old guy. I've gone up the technical ranks to run a couple of significant software development groups; suffered the crash and now code for a living. I haven't coded in every programing language known, but then, I've got quite a few nothes on my pocket protector. I love C# but I don't think I've typed so much since the days of 'Big 8' COBOL. I get a chuckle on how much I have to type to get something so small done. I thought I'd seen everything when I found that a \n\r was replaced by an 'Environment.Linefeed'. But I really had to grin when I googled to find that to get my application path I needed to enter: string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); It works but I think I've only got another C# project before I'll need to replace my keyboard. I think we need a contest on what is the longest statement possible in c# to retrieve a smiple result. There are 8 dots between the = sign and the ; in the above snippet. :-D:-D:-D:-D
betterc wrote: But I really had to grin when I googled to find that to get my application path I needed to enter: string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); Environment.CurrentDirectory also gets the application path. It's a bit easier on the keyboard. :) betterc wrote: I think we need a contest on what is the longest statement possible in c# to retrieve a smiple result. There are 8 dots between the = sign and the ; in the above snippet. I once came across (alright, wrote :|) this code to decrypt a file:
string Decrypted = System.Text.ASCIIEncoding.ASCII.GetString(new System.Security.Cryptography.TripleDESCryptoServiceProvider().CreateDecryptor(System.Text.Encoding.ASCII.GetBytes(xdoc.SelectSingleNode(System.Configuration.ConfigurationSettings.AppSettings["key"]).InnerText), System.Text.Encoding.ASCII.GetBytes(xdoc.SelectSingleNode(System.Configuration.ConfigurationSettings.AppSettings["iv"]).InnerText)).TransformFinalBlock(System.Convert.FromBase64String(System.IO.File.OpenText(System.Configuration.ConfigurationSettings.AppSettings["filepath"]).ReadToEnd()), 0, System.Configuration.ConfigurationSettings.AppSettings["length"]));
Dan -
betterc wrote: when I googled to find that to get my application path I needed to enter Have you tried the property: Application.ExecutablePath Assuming you are working on a WinForm app.. Rocky <>< www.HintsAndTips.com www.MyQuickPoll.com - 2004 Election poll is #33 www.GotTheAnswerToSpam.com
Wow, that's pretty good but it returns the path plust the executable .exe file. So I'll have to strip off the xxx.exe. BTW the above example I used (which I got off of MSDN) retuns the path prepended with "file:\". So there I have to strip the begining off. So one way or the other it will take 2 statments to get the path to the applicaiton. Again, I'm not complaining just stunned once in a while. cb :-D:-D
-
I'm an old guy. I've gone up the technical ranks to run a couple of significant software development groups; suffered the crash and now code for a living. I haven't coded in every programing language known, but then, I've got quite a few nothes on my pocket protector. I love C# but I don't think I've typed so much since the days of 'Big 8' COBOL. I get a chuckle on how much I have to type to get something so small done. I thought I'd seen everything when I found that a \n\r was replaced by an 'Environment.Linefeed'. But I really had to grin when I googled to find that to get my application path I needed to enter: string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); It works but I think I've only got another C# project before I'll need to replace my keyboard. I think we need a contest on what is the longest statement possible in c# to retrieve a smiple result. There are 8 dots between the = sign and the ; in the above snippet. :-D:-D:-D:-D
betterc wrote: I thought I'd seen everything when I found that a \n\r was replaced by an 'Environment.Linefeed'. Yes, but you can use \n\r, you just won't be guarenteed that it will always work ( i.e. Environment.NewLine will work no matter what the system requires to achieve that result ). betterc wrote: string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); I doubt this is the quickest way to do this, but having said that, if C# suffers from anything, it's forced object orientation, which means, for example, that Floor is Math.Floor, because everything needs to live in a class. You could also have made the code more readable by a few using statements at the top of the class. :-) Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
-
betterc wrote: But I really had to grin when I googled to find that to get my application path I needed to enter: string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); Environment.CurrentDirectory also gets the application path. It's a bit easier on the keyboard. :) betterc wrote: I think we need a contest on what is the longest statement possible in c# to retrieve a smiple result. There are 8 dots between the = sign and the ; in the above snippet. I once came across (alright, wrote :|) this code to decrypt a file:
string Decrypted = System.Text.ASCIIEncoding.ASCII.GetString(new System.Security.Cryptography.TripleDESCryptoServiceProvider().CreateDecryptor(System.Text.Encoding.ASCII.GetBytes(xdoc.SelectSingleNode(System.Configuration.ConfigurationSettings.AppSettings["key"]).InnerText), System.Text.Encoding.ASCII.GetBytes(xdoc.SelectSingleNode(System.Configuration.ConfigurationSettings.AppSettings["iv"]).InnerText)).TransformFinalBlock(System.Convert.FromBase64String(System.IO.File.OpenText(System.Configuration.ConfigurationSettings.AppSettings["filepath"]).ReadToEnd()), 0, System.Configuration.ConfigurationSettings.AppSettings["length"]));
Dan -
Wow, that's pretty good but it returns the path plust the executable .exe file. So I'll have to strip off the xxx.exe. BTW the above example I used (which I got off of MSDN) retuns the path prepended with "file:\". So there I have to strip the begining off. So one way or the other it will take 2 statments to get the path to the applicaiton. Again, I'm not complaining just stunned once in a while. cb :-D:-D
betterc wrote: So I'll have to strip off the xxx.exe. Easily done in the same line with a Regex. :-) Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
-
betterc wrote: So I'll have to strip off the xxx.exe. Easily done in the same line with a Regex. :-) Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
Or how about System.IO.Path.GetFileNameWithoutExtension? ;) [EDIT]Derrr. That's what I get for trying to be a smart ass. It's actually System.IO.Path.GetDirectoryName() [/EDIT]
Lest some forgot their humour pill this morning: I am writing this with Moz (actually FireFox but still Moz) and love the damned browser. It's a joke, see. -Paul Watson on FireFox
-
Most Z80 instructions were 2~4 letters (JP, LD, CALL, BCD, JNZ, JZ). All the 16-bit registers were two letters (AF, BC, DE, HL, IX, IY), but could be used as two 8-bit registers with only one letter. So, the following line was a valid Z80 instruction:
LD B,D
In C#, this would be the following:
byte B;
byte D;
B = D;I don't know why, but I do prefer working in C# than in Z80, even though I type more. And, maybe, Intelissense can help you :-D Yes, even I am blogging now!
Daniel Turini wrote: In C#, this would be the following: I disagree. Since "B" and "D" are registers that were already defined, declaring them with: byte B; byte D; is technically not correct, IMO, since in Z80, they are already "declared". So, "LD B,D" in C# would actually be "B=D;" which is 3 characters LESS! :-D Marc Microsoft MVP, Visual C# MyXaml MyXaml Blog Hunt The Wumpus RealDevs.Net
-
betterc wrote: I thought I'd seen everything when I found that a \n\r was replaced by an 'Environment.Linefeed'. Yes, but you can use \n\r, you just won't be guarenteed that it will always work ( i.e. Environment.NewLine will work no matter what the system requires to achieve that result ). betterc wrote: string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); I doubt this is the quickest way to do this, but having said that, if C# suffers from anything, it's forced object orientation, which means, for example, that Floor is Math.Floor, because everything needs to live in a class. You could also have made the code more readable by a few using statements at the top of the class. :-) Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
My Floor lives in My House, not in a class. Jon ;P
-
My Floor lives in My House, not in a class. Jon ;P
So you use
House.Floor()
instead ofMath.Floor()
? ;P :rolleyes:Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
betterc wrote: But I really had to grin when I googled to find that to get my application path I needed to enter: string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); Environment.CurrentDirectory also gets the application path. It's a bit easier on the keyboard. :) betterc wrote: I think we need a contest on what is the longest statement possible in c# to retrieve a smiple result. There are 8 dots between the = sign and the ; in the above snippet. I once came across (alright, wrote :|) this code to decrypt a file:
string Decrypted = System.Text.ASCIIEncoding.ASCII.GetString(new System.Security.Cryptography.TripleDESCryptoServiceProvider().CreateDecryptor(System.Text.Encoding.ASCII.GetBytes(xdoc.SelectSingleNode(System.Configuration.ConfigurationSettings.AppSettings["key"]).InnerText), System.Text.Encoding.ASCII.GetBytes(xdoc.SelectSingleNode(System.Configuration.ConfigurationSettings.AppSettings["iv"]).InnerText)).TransformFinalBlock(System.Convert.FromBase64String(System.IO.File.OpenText(System.Configuration.ConfigurationSettings.AppSettings["filepath"]).ReadToEnd()), 0, System.Configuration.ConfigurationSettings.AppSettings["length"]));
Dandnmanner wrote: I once came across (alright, wrote :|) this code to decrypt a file: :wtf:!!
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
I'm an old guy. I've gone up the technical ranks to run a couple of significant software development groups; suffered the crash and now code for a living. I haven't coded in every programing language known, but then, I've got quite a few nothes on my pocket protector. I love C# but I don't think I've typed so much since the days of 'Big 8' COBOL. I get a chuckle on how much I have to type to get something so small done. I thought I'd seen everything when I found that a \n\r was replaced by an 'Environment.Linefeed'. But I really had to grin when I googled to find that to get my application path I needed to enter: string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); It works but I think I've only got another C# project before I'll need to replace my keyboard. I think we need a contest on what is the longest statement possible in c# to retrieve a smiple result. There are 8 dots between the = sign and the ; in the above snippet. :-D:-D:-D:-D
betterc wrote: I get a chuckle on how much I have to type to get something so small done. I thought I'd seen everything when I found that a \n\r was replaced by an 'Environment.Linefeed'. As other people have stated, you can always use '\r\n'. But .NET is supposed to be platform independant, so if someone was trying to run your application on MONO on a linux, then they would probably be very disappointed if the output files from your program were splattered with '\r\n' instead of just '\n'. "After all it's just text at the end of the day. - Colin Davies "For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
-
Or how about System.IO.Path.GetFileNameWithoutExtension? ;) [EDIT]Derrr. That's what I get for trying to be a smart ass. It's actually System.IO.Path.GetDirectoryName() [/EDIT]
Lest some forgot their humour pill this morning: I am writing this with Moz (actually FireFox but still Moz) and love the damned browser. It's a joke, see. -Paul Watson on FireFox
-
betterc wrote: I get a chuckle on how much I have to type to get something so small done. I thought I'd seen everything when I found that a \n\r was replaced by an 'Environment.Linefeed'. As other people have stated, you can always use '\r\n'. But .NET is supposed to be platform independant, so if someone was trying to run your application on MONO on a linux, then they would probably be very disappointed if the output files from your program were splattered with '\r\n' instead of just '\n'. "After all it's just text at the end of the day. - Colin Davies "For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
jan larsen wrote: But .NET is supposed to be platform independant Hmmm.. Really? I know people are trying to make it that way but it is built to be Platform "dependant"... Rocky <>< www.HintsAndTips.com www.MyQuickPoll.com - 2004 Election poll is #33 www.GotTheAnswerToSpam.com
-
jan larsen wrote: But .NET is supposed to be platform independant Hmmm.. Really? I know people are trying to make it that way but it is built to be Platform "dependant"... Rocky <>< www.HintsAndTips.com www.MyQuickPoll.com - 2004 Election poll is #33 www.GotTheAnswerToSpam.com
Rocky Moore wrote: but it is built to be Platform "dependant"... Not really, it's like with Java, you just need the runtime engine for your target platform. At the time you only get the full compliance on (some) Win32, but there is a limited runtime for Linux. I agree though that there are som errors in the design, eg. The Form class which exposes the native win32/win64 handle. But that is where the skill as a programmer comes in :-), it should be possible to work around such issues. Java actually got a few such issues too, but they are a bit harder to find and exists solely on rarely used operations, such as killing threads explicitly, which wasn't fully supported on Java 1.1 for HP-UX. "After all it's just text at the end of the day. - Colin Davies "For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus