13

I am trying to learn Windows.Forms, and while I have Visual Studio (edit, my mistake obviously), I feel that I learn much more effectively by doing everything in Notepad. I have searched everywhere for a tutorial that takes this approach. I finally got started with http://www.geekpedia.com/tutorial33_Windows-forms-programming.html, but after the first example, it too begins working with multiple files? somehow generated with Visual Studio. How can I do this in Notepad? Can anyone point me somewhere helpful?

Thanks!

**While the overwhelming response seems seems strongly against this and I started to be convinced, I saw SmokingRope talking about it being as simple as writing all classes into one file. This is what I have been doing up till now for sizable, just non Windows.Form projects into. Can you maybe help explain how those necessary files can be included using this method?*

Janusz
  • 187,060
  • 113
  • 301
  • 369
Nona Urbiz
  • 4,873
  • 16
  • 57
  • 84
  • What version of Visual Basic do you have? – John Saunders Aug 06 '09 at 02:16
  • 9
    Please for the love of all things holy, don't. Just don't. – user144051 Aug 06 '09 at 02:31
  • 7
    Just ignore the skeptics and give it a go. It isn’t that hard and in the process you will learn a lot more about how .Net actually works. Later on you can always go back to using the Visual Studio IDE. – jussij Aug 06 '09 at 03:11
  • 2
    @jussij: The .NET WinForms project autogenerated code does not do much. Look at the Program.cs file, look at your form's InitializeComponent method and now there is no need to use Notepad. – Ed S. Aug 06 '09 at 06:31
  • 6
    I just wanted to say "go for it" and props-to-you for taking on the challenge. Obviously it'll be slower going, but it shows that you don't want to use Visual Studio as a crutch. There's a lot of Microsoft developers who can't do much of anything without visual Studio, and because of that they're locked-in. That said, .NET does have a variety of solid IDEs and tools that you'll need to be familiar with; and knowing them for .NET development is important. All in all I think your excercise will make you more willing to try languages with fewer wizards and tools though, and thats a good thing – STW Aug 17 '09 at 03:36

17 Answers17

33

Seriously... I admire your fire, but you are out of your mind! What you can possibly hope to learn about .NET with NotePad that you couldn't learn a zillion times faster with Visual Studio? It's like asking, "I want to learn to drive a car. I have put wheels on my couch. What should I do next?"

I mean no disrespect, but make friends with Visual Studio and get busy learning. You're wasting your time otherwise.

rp.
  • 17,483
  • 12
  • 63
  • 79
  • 1
    "faster with .NET" should be "Visual Studio" I think? doesn't quite make sense lol. But yea, you and Scott say good things. :) – Zack Aug 06 '09 at 02:40
  • 3
    This reminds me of every time a new feature is released, people bag it saying no one would use that etc. As Linux IDE's are just so terrible the only argument they have is "you aren't a real programmer unless you use VIM". The only thing my employer cares about is how quickly I can complete my task. I spend less time fighting with the language and more time on the code :) – Spence Aug 06 '09 at 02:48
  • 1
    In IDE some things might get unnoticed that are crucial for the application to run. (Like auto generated code) If you type them in notepad you have no chance not to notice them. For example I know many people developing happily with Silverlight doesn't have any idea about what InitializeComponent() is doing behind the scene. – Tanmoy Aug 22 '09 at 05:24
  • @Spence Honestly, I disagree with the statement "Linux IDE's are just so terrible". A good Eclipse, NetBeans or MonoDevelop installation provides lots of features, maybe even more than Visual Studio does (and often in a better way). VIM and Emacs can provide these features too, but generally with a different approach to user interface (not judging as better or worse, just different). That being said, I think there are lots of "real programmers" using different "real tools", and that's not bad. Actually, I even suspect that many ideas of Windows 8 came from GNOME 3. – LRMAAX Feb 26 '15 at 03:31
  • 1
    That comment is nearly 6 years old. Eclipse has come a LONG way since I wrote that. – Spence Feb 26 '15 at 04:06
10

It is actually quite easy to code C# outside of the IDE. It will basically come down to using the csc.exe compiler from the command line prompt.

The hardest part of this process is making sure the environment variables are correctly configure and Microsoft provides the vsvars32.bat batch file to do exactly that.

Here is a short tutorial on how to do use this batch file and the compiler from the command line: http://www.zeusedit.com/forum/viewtopic.php?t=1235

And an even better, but slightly more complicate approach is to use MsBuild utility to manage the building of the project: http://www.zeusedit.com/forum/viewtopic.php?t=2518

Finally you can even use the external C# Debugger to debug you programs: http://www.zeusedit.com/forum/viewtopic.php?t=2507

jussij
  • 10,370
  • 1
  • 33
  • 49
  • 4
    You can also make nails out of old welding rods--thereby spending all of your time making nails. Or, you could buy a sack of nails and start building something! – rp. Aug 06 '09 at 06:28
6

I am going against the grain here... But I think that your idea is not such a bad one... especially for a small project.

But using Notepad (or at LEAST use Notepad++) will teach you more about MSBuild and the VBC or CSC compiler syntax than it will teach you about the language features. The best way to learn the language, is, as other have said, using Visual Studio. The intellisense is a great way to learn.

But it also makes us lazy and it is true that we don't have to memorize as much...and sometimes having things memorized comes in handy. (ie.... I am at a customer and logged in remotely to the servers... no visual studio is installed... BUT... yippee... .NET 2 is there... at that moment you will have appreciated the exercise...)

Honestly, to do this for a reasonably small project I think would be a good exercise in learning. I say go for it. Hell, I might even join you.

But, that said, I think the very best way to do it would be to use both methods side-by-side. For example... If you want to use multiple files the way to do that is to create a folder and put an vbproj (or csproj) file in it. MSBuild.exe receives vbproj files (and sln files for that matter) as arguments. So, one of the quickest ways to learn the vbproj file syntax is to use visual studio to create a project... and then open the vbproj file in Notepad++.

The problem is that Visual Studio IS SO AWESOME BECAUSE it abstracts so much away from the developer. But it is silly to not acknowledge there is a downside to that. That abstraction means that we don't need to have as deep an understanding. Things just work automagically. So I say dig a little deeper. I don't think you will regret it.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Seth Spearman
  • 6,710
  • 16
  • 60
  • 105
  • Just to clarify...vbproj and csproj files are NOT the only way to use multiple files. I am pretty sure that the compilers themselves (vbc.exe and csc.exe) will recieve multiple files as command arguments. Seth – Seth Spearman Aug 17 '09 at 03:26
4

Your best approach is really to learn how to write code from within Visual Studio. You gain a lot of coding assistance (IntelliSense, syntax checking, etc.) that will help you learn the language.

If you really want to use Notepad, then you create as few or as many files as you want and then compile them in to an assembly using the command line compiler by listing each file as an input to the compiler.

The reality of this is that using notepad and the command line compiler is possible but very cumbersome and almost never used outside of showing simple "Hello, world" type examples.

Scott Dorman
  • 42,236
  • 12
  • 79
  • 110
2

Assuming that the thing you want to avoid is magically-generated-code and visual designers, you can just open the System.Windows.Forms namespace and start coding against the APIs. Start with that first example, and then programmatically add buttons and textboxes and whatnot. You don't have to create a forms project or work with the designers, you can just 'write code' in VS and turn off all the magic.

If you're looking for example code, you might consider looking at F# samples, e.g. the UI stuff at

http://code.msdn.microsoft.com/fsharpsamples

for ideas of a few basic controls you can add to forms to do basic UI stuff.

Brian
  • 117,631
  • 17
  • 236
  • 300
2

You can write multiple classes in a single C# file (despite the generally accepted best-practice of putting one class per file):

using System;
namespace Test{
  class Class1{ }
  class Class2{ }
}

You also could look into how the MSBuild system works from the commandline. I believe you will still have to maintain a project file (xml type syntax, use visual studio to create a project and then open that in notepad for an example) but i don't have any experience with it personally.

It's possible to do it all from notepad and the command prompt. You will probably find it to be a little more time consuming however.

hannasm
  • 1,951
  • 4
  • 16
  • 25
1

If you want to learn c# and winforms, part of the skill set you need is being proficient in Visual Studio.

You can do things in Notepad for awhile (I wrote some web services in notepad once because I didn't have VS available), but eventually you will want to take advantage of the tools available in VS.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
1

I highly recommend you use Visual Studio (Microsoft offers free Express versions that will meet your needs). Learning the syntax of the language is wonderful, but you must be able to work within the VS environment to be truly successful in C# (and any of the .NET languages). It benefits you more to do it right and learn it all together rather than try and piece it together later. Just my own two cents.

Matt Dewey
  • 137
  • 1
  • 1
  • 11
1

Just to repeat what's already said, again with no disrespect, you are not going to learn .NET in notepad. It's just not probable. Not only are you not be productive, but you're also not going to learn the tools used in the industry, best practices, and other important factors about .NET. It's not just about sitting down and writing code. By limiting yourself to notepad, it's like limiting yourself to one meal a month: you lack the nutrition needed to keep moving forward at a good pace.

Utilize the tools and resources available to you. Limiting yourself like that is a kick in the rear end.

David Anderson
  • 13,558
  • 5
  • 50
  • 76
1

Use sharpdevelop (Windows) or monodevelop (*nix). Both have Windows.Form support. Although they dont offer as much as VS, they'll at least get you started. I've never used the VS Express edition, so I don't know what it's limitations are.

Joseph Yaduvanshi
  • 20,241
  • 5
  • 61
  • 69
1

Note that notepad is not even the equal of vi not to speak of vim.

If you want to use a text editor then you could try it but I don't see the point of using notepad. Use a real text editor, not necessarily vim/emacs, you could pick a nice gui text editor like notepad++ or kate.

Notepad can't even display unix line endings(I think).

Roman A. Taycher
  • 18,619
  • 19
  • 86
  • 141
0

Go download an Express edition of Visual Studio. I understand the possibility of thoroughly learning this via notepad, but with a free IDE out there, it makes no sense.

Brandon
  • 13,956
  • 16
  • 72
  • 114
0

if u have something against MS or VS.net u can try sharpdevelop http://www.icsharpcode.net/OpenSource/SD/

last time i looked it was xcopy deployable :)

Simon
  • 33,714
  • 21
  • 133
  • 202
0

I don't know where to find tutorials, but the approach is pretty straightforward: import System.Windows.Forms, derive a class from Form, and give it a .Show(). Your components are members of the class, and can be positioned using their respective position/size properties. Events are handled through delegates.

I do see where this technique is useful, though I'd use a decent IDE instead of Notepad. .NET is just too prolific. Knowing how to construct forms on the fly can come in handy.

If you're looking for an alternate IDE, check out icSharpCode's SharpDevelop.

Also, look into JScript.NET tutorials - there is no forms editor for that language, as inheritance simply isn't possible. But it's still based on .NET, so the basic motions are the same. Here's a decent one:

http://www.webreference.com/js/column117/

Barry Burns
  • 93
  • 1
  • 5
0

I know this is answered by strangely I haven't seen anyone talk about NAnt.

For years I developed in TextPad, with some syntax highlighting, + NAnt to do my builds. These days it'd be even easier as you can have your buildserver prep a proper msbuild for you (CC.NET + NAnt).

I also learned about a few things that physically couldn't do in Visual Studio (at the time it was .net 1.1). Definitely a good experience, and I'd recommend it really. Probably not for winforms though, because the designer is actually useful for that.

Noon Silk
  • 54,084
  • 6
  • 88
  • 105
  • silky, What do you mean that NANT or cc.net can "prep an msbuild server?" You have my curiosity. Are you saying they can actually create the proj files on the fly based on other metadata? – Seth Spearman Aug 17 '09 at 04:03
  • You can use NAnt to call MSBuild to do the build from your project files. – Noon Silk Aug 17 '09 at 04:05
0

i am a notepad user. :) i don't have visual studio installed on my computer.

this is what im doing.

1st u must register your .net framework folder on Environmen Variables.. Path or run on CMD this lines path=%path%;(this is where ur .net framework address were) (ex path=%path%;C:\Windows\Microsoft.NET\Framework\v4.0.30319) then hit enter

2nd to compile a single notepad(save as .cs), locate the destination of the file using cmd. then. type "csc nameOfCS.cs" for multi file.. "csc ManinCsForname.cs classes.cs classes.cs" it will compile as exe. for more command. "csc /?"

its ok to use Visual Studio. but if you want to become more familiar with C# and structure. or can make a system on any PC. without using any IDE. u can do this.

rem
  • 1
0

Not using Notepad will help. Crimson Editor or TextPad or others have line numbering, syntax highlighting and many features you'd need. I'm sure Notepad has file size limitations which you might run into.

The sans-IDE element I can only fully answer from a Java point of view. I've done a fair amount of Java UI development using Crimson Editor, the Java SDK, batch files and/or either ANT or Maven at times. If you developing UI code that's generic or does a fair amount in dynamically then its ok. If your work involves designing many different specific Forms (i.e. screens that have many customer forms and aren't subject too much reuse) then the Designer features of the IDE are extremely useful.

However, I have found .NET IDE development a little frustrating coming from the above model of Java development.