Is there an easier way to find things in C#
-
Please tell me there's an easier way. Here are a few examples of my recent pain: It took me a day and a half of searching the Web, MSDN, and 6 books about C# before I found out there was an OpenFilaDialog class for asking the user which file they wanted my app to open. It took me mere seconds to code a KeyDown event on my RichTextBox, and to figure out that I needed to use KeyEventArgs.Control to see if the control key was pressed, but it took several hours of searching to figure out I needed to compare Keys.L to KeyEventArgs.KeyCode to find out if L was pressed. It took me hours of searching to find out that "Cursor.Current=Cursors.WaitCursor;" would change the mousepointer to the hourglass while my program retrieved from the database. I am not stupid, I have been programming for over 25 years, in RPG, COBOL, TOTAL, ADS/O, PowerBuilder, and probably others along the way. My whole department is going to come to me when they have the question: "In .NET, how do I...?", and I don't want to tell them I'll get back to them in a week. I bought "C# for Experienced Programmers" by Deitel because it was the only book I could find that told me about the OpenFileDialog class. It did not help me with the other two situations I had. I just have to beleive there is a better way...
-
Please tell me there's an easier way. Here are a few examples of my recent pain: It took me a day and a half of searching the Web, MSDN, and 6 books about C# before I found out there was an OpenFilaDialog class for asking the user which file they wanted my app to open. It took me mere seconds to code a KeyDown event on my RichTextBox, and to figure out that I needed to use KeyEventArgs.Control to see if the control key was pressed, but it took several hours of searching to figure out I needed to compare Keys.L to KeyEventArgs.KeyCode to find out if L was pressed. It took me hours of searching to find out that "Cursor.Current=Cursors.WaitCursor;" would change the mousepointer to the hourglass while my program retrieved from the database. I am not stupid, I have been programming for over 25 years, in RPG, COBOL, TOTAL, ADS/O, PowerBuilder, and probably others along the way. My whole department is going to come to me when they have the question: "In .NET, how do I...?", and I don't want to tell them I'll get back to them in a week. I bought "C# for Experienced Programmers" by Deitel because it was the only book I could find that told me about the OpenFileDialog class. It did not help me with the other two situations I had. I just have to beleive there is a better way...
My recommendation is to skim through the table of contents for the Class Library[^] to see what classes there are. I've seen many times where people are looking for something or end up writing something over when there was a class already for it. You wouldn't necessarily have to read about all the classes (at least the ones in which you're interested or the name is not self-explanitory enough) but just see what there is. Also being familiar with the major abstract classes like
System.Windows.Forms.Control
is important. They define much of the functionality of their derivatives and understanding how they work is important. I also recommend that when you get more familiar with classes you see how they work under the covers using ildasm.exe from the .NET Framework SDK or a decompilers like .NET Reflector[^]. It's really just a case of getting to know the classes for such a large class library. Guessing also helps. If you're looking for an open file dialog, type "OpenFileDialog" (case not important) in the index of your Visual Studio Combined Help collection in the Visual Studio program group in yoru start menu. The local index is much easier to search than MSDN since there it's a keyword search, while and index like the combined collection (or the quarterly MSDN Library if you subscribe) is designed to help you be more efficient. When you get used to the class naming conventions of the .NET base class library (BCL) it gets easier to guess what a useful class name is. Type it in the index and read about it. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog] -
Please tell me there's an easier way. Here are a few examples of my recent pain: It took me a day and a half of searching the Web, MSDN, and 6 books about C# before I found out there was an OpenFilaDialog class for asking the user which file they wanted my app to open. It took me mere seconds to code a KeyDown event on my RichTextBox, and to figure out that I needed to use KeyEventArgs.Control to see if the control key was pressed, but it took several hours of searching to figure out I needed to compare Keys.L to KeyEventArgs.KeyCode to find out if L was pressed. It took me hours of searching to find out that "Cursor.Current=Cursors.WaitCursor;" would change the mousepointer to the hourglass while my program retrieved from the database. I am not stupid, I have been programming for over 25 years, in RPG, COBOL, TOTAL, ADS/O, PowerBuilder, and probably others along the way. My whole department is going to come to me when they have the question: "In .NET, how do I...?", and I don't want to tell them I'll get back to them in a week. I bought "C# for Experienced Programmers" by Deitel because it was the only book I could find that told me about the OpenFileDialog class. It did not help me with the other two situations I had. I just have to beleive there is a better way...
I do as you, but I often look at the functions and members of the class, and then I look at the index, that's really fast, after that I search msnd, that amost never give's me answers. I try to figure it out in another way insted. I'm also a programmer that always write's my own code, with C#, it's a lot easier, becouse of the framework. I'll need to learn the skill to use code of others... The one and only Niklas Ulvinge aka IDK
-
Please tell me there's an easier way. Here are a few examples of my recent pain: It took me a day and a half of searching the Web, MSDN, and 6 books about C# before I found out there was an OpenFilaDialog class for asking the user which file they wanted my app to open. It took me mere seconds to code a KeyDown event on my RichTextBox, and to figure out that I needed to use KeyEventArgs.Control to see if the control key was pressed, but it took several hours of searching to figure out I needed to compare Keys.L to KeyEventArgs.KeyCode to find out if L was pressed. It took me hours of searching to find out that "Cursor.Current=Cursors.WaitCursor;" would change the mousepointer to the hourglass while my program retrieved from the database. I am not stupid, I have been programming for over 25 years, in RPG, COBOL, TOTAL, ADS/O, PowerBuilder, and probably others along the way. My whole department is going to come to me when they have the question: "In .NET, how do I...?", and I don't want to tell them I'll get back to them in a week. I bought "C# for Experienced Programmers" by Deitel because it was the only book I could find that told me about the OpenFileDialog class. It did not help me with the other two situations I had. I just have to beleive there is a better way...
Like with all "new" (I mean "new" as in "new to you") API/libraries, it is just a matter of figuring out the style or pattern to the thing (what their methodology for placing what classes where). Once you realize that it is easy to search for things you aren't exactly sure where they exist. I would recommend getting familiar with the namespace layout. Once you realize that all UI elements are under
System.Windows.Forms
you could easily find theOpenFileDialog
class. Lo and behold,SaveFileDialog
is there as well! Once you realize the IO is inSystem.IO
you can find all sorts of ways to stream data. Picking up a new API/library is like learning to ride a bike all over again. It is a little painful but the real way to do it is jump on and go. It might have taken you a bit to findOpenFileDialog
but it will get faster the more familiar you get with the object layout. -
My recommendation is to skim through the table of contents for the Class Library[^] to see what classes there are. I've seen many times where people are looking for something or end up writing something over when there was a class already for it. You wouldn't necessarily have to read about all the classes (at least the ones in which you're interested or the name is not self-explanitory enough) but just see what there is. Also being familiar with the major abstract classes like
System.Windows.Forms.Control
is important. They define much of the functionality of their derivatives and understanding how they work is important. I also recommend that when you get more familiar with classes you see how they work under the covers using ildasm.exe from the .NET Framework SDK or a decompilers like .NET Reflector[^]. It's really just a case of getting to know the classes for such a large class library. Guessing also helps. If you're looking for an open file dialog, type "OpenFileDialog" (case not important) in the index of your Visual Studio Combined Help collection in the Visual Studio program group in yoru start menu. The local index is much easier to search than MSDN since there it's a keyword search, while and index like the combined collection (or the quarterly MSDN Library if you subscribe) is designed to help you be more efficient. When you get used to the class naming conventions of the .NET base class library (BCL) it gets easier to guess what a useful class name is. Type it in the index and read about it. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog]To quote you: '...If you're looking for an open file dialog, type "OpenFileDialog"..' Therein lies the crux of the problem. If I had known that it was called "OpenFileDialog" I wouldn't even have needed to search in the first place because autocomplete will tell me all about the methods, attributes, and events for that class. I searched for "openfile", "fileopen", "getfile", getfilename", "getfileopenname" (The function we use in PowerBuilder), "filechoose", "filename", and a hundred other search strings. No reasonable results came back from MSDN online, the WEB in general, or any books except the one I bought. When I wanted to do the mousepointer thing, the first search string I entered was "cursor", but I got back 100 billion useless VB6, foxpro, and C++ answers for how to use database cursors. So I assumed I was on the wrong track and should search for "mouse", "mousepointer", "mouseicon", "pointer", etc. All to no avail. Your idea about perusing the class library's table of contents is not a bad idea for a rainy day, but when I have a specific question about something in C#, there doesn't seem to be a resource available to me. IF MSDN online would let me filter my search PROPERLY, it might end up being the answer, but it's totally useless as it sits now. I was hoping I could find a searchable reference resource (online or book) on C# specifically.
-
To quote you: '...If you're looking for an open file dialog, type "OpenFileDialog"..' Therein lies the crux of the problem. If I had known that it was called "OpenFileDialog" I wouldn't even have needed to search in the first place because autocomplete will tell me all about the methods, attributes, and events for that class. I searched for "openfile", "fileopen", "getfile", getfilename", "getfileopenname" (The function we use in PowerBuilder), "filechoose", "filename", and a hundred other search strings. No reasonable results came back from MSDN online, the WEB in general, or any books except the one I bought. When I wanted to do the mousepointer thing, the first search string I entered was "cursor", but I got back 100 billion useless VB6, foxpro, and C++ answers for how to use database cursors. So I assumed I was on the wrong track and should search for "mouse", "mousepointer", "mouseicon", "pointer", etc. All to no avail. Your idea about perusing the class library's table of contents is not a bad idea for a rainy day, but when I have a specific question about something in C#, there doesn't seem to be a resource available to me. IF MSDN online would let me filter my search PROPERLY, it might end up being the answer, but it's totally useless as it sits now. I was hoping I could find a searchable reference resource (online or book) on C# specifically.
You need to limit your scope. If you simply search for "cursor" you will find lots of extraneous hits, but "mouse cursor" would've gotten rid of all those SQL database cursor documents and "mouse cursor in .NET" would've gotten you closer. Using the Visual Studio Combined Collection is the best way, IMO, because - at least in the case of "cursor" typing it in the index (not search) would've given you relatively few - but more appropriate - hits. Indexes are more conceptual where keyword searches are almost always useless unless you get really specific. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog]
-
My recommendation is to skim through the table of contents for the Class Library[^] to see what classes there are. I've seen many times where people are looking for something or end up writing something over when there was a class already for it. You wouldn't necessarily have to read about all the classes (at least the ones in which you're interested or the name is not self-explanitory enough) but just see what there is. Also being familiar with the major abstract classes like
System.Windows.Forms.Control
is important. They define much of the functionality of their derivatives and understanding how they work is important. I also recommend that when you get more familiar with classes you see how they work under the covers using ildasm.exe from the .NET Framework SDK or a decompilers like .NET Reflector[^]. It's really just a case of getting to know the classes for such a large class library. Guessing also helps. If you're looking for an open file dialog, type "OpenFileDialog" (case not important) in the index of your Visual Studio Combined Help collection in the Visual Studio program group in yoru start menu. The local index is much easier to search than MSDN since there it's a keyword search, while and index like the combined collection (or the quarterly MSDN Library if you subscribe) is designed to help you be more efficient. When you get used to the class naming conventions of the .NET base class library (BCL) it gets easier to guess what a useful class name is. Type it in the index and read about it. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog]I don't have "Visual Studio Combined Help collection in the Visual Studio program group in your start menu". Maybe that is the real problem here. Is it something I did not install? I have VS 2003 and .Net Framework 1.1. I was relying too much on web searching, and not on searching specific help files on my own computer. I do have "MSDN Library for Visual Studio .NET 2003" on my start menu, but I had not seen that because it is so well hidden. Maybe all my complaining was for nought. I searched it for "openfile" and it took me right to the OpenFileDialog class. I searched for "mouse pointer", "mousepointer" and "mouse cursor", which didn't get me good results, but when I searched for "cursor" it went right to the Cursor and Cursors classes, which may have helped me, though the examples there were stupid. I couldn't find a good search string for the Keys.L thing, but I think if I was on the KeyEventArgs class, I may have been able to figure out the Keys.L thing. You may have opened a whole new world for me here.
-
I don't have "Visual Studio Combined Help collection in the Visual Studio program group in your start menu". Maybe that is the real problem here. Is it something I did not install? I have VS 2003 and .Net Framework 1.1. I was relying too much on web searching, and not on searching specific help files on my own computer. I do have "MSDN Library for Visual Studio .NET 2003" on my start menu, but I had not seen that because it is so well hidden. Maybe all my complaining was for nought. I searched it for "openfile" and it took me right to the OpenFileDialog class. I searched for "mouse pointer", "mousepointer" and "mouse cursor", which didn't get me good results, but when I searched for "cursor" it went right to the Cursor and Cursors classes, which may have helped me, though the examples there were stupid. I couldn't find a good search string for the Keys.L thing, but I think if I was on the KeyEventArgs class, I may have been able to figure out the Keys.L thing. You may have opened a whole new world for me here.
You have to install the help collection after installing Visual Studio. What you have would be aggregated - along with third-party components some times - with the Visual Studio Combined Collection (or something similar to that; don't remember off-hand what the exact wording is). This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog]