Creating Your First C# Program - 02
- Posted: Nov 21, 2011 at 9:08 AM
- 175,089 Views
- 89 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Right click “Save as…”
This lesson teaches you how to create a simple application—first using Windows Notepad and the C# Command Line Compiler, and then by using Visual Studio or Visual C# Express Edition. The point of this episode is to demonstrate how utilizing an Integrated Development Environment (IDE) is far easier than attempting to work using a loose collection of windows and tools. The video concludes with an explanation of common solutions to the many different problems you might encounter as you first begin writing and compiling code.
Download the source code for Creating Your First C# Program
IMPORTANT UPDATE: Before you watch this lesson, please make sure you have watched this video to learn about changes to Visual Studio since this series was originally recorded.
Already have a Channel 9 account? Please sign in
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
Awsome
Thanks!
Excellent. Can't wait to work through the rest of the series
is it my pc problem or what i can see anything you type on the note pad .
i only see funny char.
Video resolution too low for a big screen (1680 X 1050) cant see the words on notepad
Thank you for great tutorial that i was understood foundamental of C# language
One thing to note that your VDO is not high resolution that it doesn't see your code at all.
Thank you.
I can only read parts of what you are typing at 2:36 and beyond. Otherwise some of the words/letters are hard or not possible to read because the type is so small.
Very clean and awesome
Awesome!!
@Chairat, @Justin ... and future reference for others ...
Short story: If you are streaming the videos you can try using the expand icon in the video player to view the video full screen. If, when in full screen mode the text is garbled, then you must DOWNLOAD the video to your computer first (see downloads to the right of the video player) to watch it using Windows Media Player (or other media player).
The videos were recorded in High Def resolution, 1280 x 720 (so, 720p).
Long story: After recording the videos, Channel 9 encodes the videos for streaming using Silverlight Smooth Streaming. Based on your bandwidth, computer processor, etc. enough video data is sent to render the video as best as possible to avoid gaps or pauses in playback. With "live video" like a movie or tv show, this usually means the video is pixelated but still acceptable. With screen cast videos where you are trying to read the small text on screen, this usually renders the text unreadable. The solution, as I mentioned previously, is to DOWNLOAD the video to your local computer THEN watch it.
Hope that helps!
Your excellent videos would be complete if we can download the exact script of your speech.
Thanks
Your excellent videos would be complete if we can download the exact script of your speech.
Thanks
Sir,
i would like u to please tell me a book which is best for learning C# with .net so that i can make my C# concepts more strong.
sir please help.
thank u
Thanks. It's really a good start for me now that I'm learning Razor. Can't wait to go through the whole process, but I'll be taking it one at a time.
By the way, what's the meaning of :
using System;
using System.Web
using System.Collections.Generic;
using System.Linq;
using System.Text;
Thanks
Heyz...!!
First of all man nicest WORK! Thanks a ton for this great help... I was starving for such help Thanks once again :)
and sir is it possible to download this complete series on my PC through torrent download..
As my streaming is too slow.. once it'll be completely downloaded i can learn from it without any waiting and interruption. please do consider my request.
And please if its possible for you to provide some guideline for MCTS preparation, please help me on this too.
ThanKS!!
@HEROLD: I believe we do talk about the using statements later in this series when I talk about Namespaces. Stay tuned!
@Naqi Agha: I believe each video has a download link at the very top of this and every Channel 9 video page. I don't know if there's a torrent for it ... I would doubt it would come directly from Channel 9, but I could be wrong.
@Rituraj Jain: For the basics, I like the Microsoft Press books, especially their Step-By-Step series, and anything written by Matthew MacDonald. (I've never met him ... no financial incentive here at all.)
Actually to do this command I had to use this command line code:
csc /t:exe /out:C:\HelloWorldcs/HelloWorld.exe C:\HelloWorldcs\HelloWorld.cs
So I had to add the C:\ to the cs file! I am using windows vista
Also is it possible to compile multiple files on the command line?
Great video, very easy to follow and the way you present it makes it so much less painful than other tutorials.
For the people that seem to be having issues with not seeing the text on Bob's notepad, hit ctrl and zoom in on your webpage, the text becomes clear as day.
Thanks.
Thanks i learn lot.
@Algorithum:Yes, it is absolutely possible. Check out this link:
http://msdn.microsoft.com/en-us/library/78f4aasd.aspx
And see this line:
That last part *.cs tells the compiler to compile all the .cs files in the directory. There are A BUNCH of command line options ... I only demo'd the tip of the iceberg.
Hope that helps! Best wishes in 2012!
Great videos. My skills are rusty, and were never great to start with,so this is a good refresher. But I suggest:
1. In Notepad, select Format ->Font before recording a video, and make the font BIG. For something as simple as HelloWorld, a size 28 font should be readable on any video stream.
2. My own "gotcha" - spaces in directory names. If you have a space, the destination string AND the target string each need to be put inside quotes.
@Alan: Hi Alan, thank you for the suggestions. Actually? I just wrapped up a new series for Channel9 two days ago and did exactly as you suggested ... not 28pt, but 18pt w/ bold. HOPEFULLY that's good enough (!!!)
re: spaces and directory names ... absolutely, and that is why I rigged the example to be created at c:\whatever instead of c:\what ever.
I agree, that can be frustrating. Fortunately, most of us rely on Visual Studio or the Express Editions to make all that stuff trivial.
Great videos
sir this is very good fundamental videos of c# thanks alot.
The C# .NET Framework tutorial is awesome.
Microsoft partners has a very good idea to build this.
At this time I`am programming in c++ but I can learning a C#.
Thanks Microsoft!
P.S Sorry my English at the moment isn't very good.
@Mamoun Saeed: @abid ali: @Aleksander: Thank you, all.
Great videos.Thanks
Thanks Bob! I dabbled a bit with C about 20 years ago...barely got past "Hello World"...hehehe. I know I am going to enjoy going thru your lessons. I consider myself a "Utilitarian" programmer. I learn what I need to accomplish the task at hand. I have managed to do this with HTML, CSS, javascript and PHP...so the little foundation I have has already helped.
These are great videos! I have no programming background, so I was intimidated to start. But your video helped me see that it's not all that complicated and crazy. Thanks a million!
I got this c:\HelloWorld\HelloWorld.cs(5,32): error CS1010: Newline in constant
Please help...
@steve: Hey Steve, could you post your code? I'll try to help you through it. Keep in mind: the purpose of the exercise was NOT to discourage you completely, just to discourage you from trying to type all your code in Notepad and compile in the command line compiler. If this doesn't work, I recommend shrugging it off and moving forward.
public class HelloWorld
{
public static void Main()
{
system.console.WriteLine("hello world!);
system.console.ReadingLine();
}
}
Hi Steve,
Please correct the code as follows:
public class HelloWorld { public static void Main() { // Please ensure that as mentioned by Bob you are typing the code with case sensitivity,so here you have to type the system.console as System.Console // Here please add quotation ( " ) near the !, which means that you are completing the string. System.Console.WriteLine("Hello World!"); //Change the ReadingLine to ReadLine System.Console.ReadLine(); } }Hope this helps!!
@Bob :
Hi Bob, i was able to clear the errors but do know what the error exactly means so Could you please clarify what is that error "NewLine in constant" ?
thens
@thens: @Steve: Thank you, thens, for the corrected code! re: your question ... I don't know for sure, but I have a feeling the error had something to do with the command line compiler and the arguments Steve set it to. It never got to the line of code: Console.ReadlingLine() ... which would obviously fail.
@Steve: Remember -- this is an exercise in preciseness ... things must be typed in EXACTLY as I do them down to the same words and punctuation. Best wishes!!!
Thanks @thens and Bob!!! Got it!!!
@BobTabor:Thanks Bob
@Steve: Welcome steve, Happy Learning & Coding
I have tried to follow your video "Creating Your First C# Program - 02" but I could not make the screen bigger and I was not able to see clearly what appeared on the screen. I apologize for this so simple question, but I would appreciatte your help.
Creating Your First C# Program - 02
Amazing videos.Thanks
@Reynaldo Guiza: Hi, and sorry you're having a problem viewing. If you're having problems viewing, I strongly recommend that you download the files to your local computer and view in full-screen. You will need to see my code throughout the series. Hope that helps!!!
Hi, I am having a problem in cmd with the exe.
Here is a screenshot of the error.
http://i.imgur.com/MWo5A.png
Never mind i went through the video again and in the notepad part i did not capitalize Main in "public static void Main()"
i am create a video player in C# application but his not complete plz help me ? plz send player sorce code my E mail ID plz
thank you Sir
Thx you:)
Great Job Sir, I want to clarify my concepts of C#, please guide me and I also want to develop my Final Year Project using it,
May I do it???
Please reply me to my e-mail id. i mentioned above
The cmd line attempt failed. Here's the information:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319>csc /t:exe /out:C:\HelloWorldtest\HelloWorld.exe C:\HelloWorldtest\HelloWorld.cs
Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
Copyright (C) Microsoft Corporation. All rights reserved.
error CS0016: Could not write to output file 'c:\HelloWorldtest\HelloWorld.exe'
-- 'The directory name is invalid. '
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319>
I would appreciate any information on how to correct this.
Thanks,
Steve
@Steve: I would make sure that the directory you are referencing is valid. Are you SURE it is spelled EXACTLY the way that you typed it into the compiler's command? ALSO don't get stuck here ... the point of this exercise was this this is really tough to get right ... and so you should be using Visual Studio because it takes care of frustrating things like this!
Best wishes!
good resources i hav ever seen....
TANKS FOR THE TUTORIAL ,I WILL SEE B/C I LIKE C#
Hi Bob,
I am excited to view your videos but I am having a very difficult time. I have tried streaming and it buffers forever. I have also tried downloading the second video twice and it took 6 or more hrs to finally get to 98% and then it failed. Can you suggest a better way to view your videos or perhaps what I'm doing wrong?
Thank you
I may have resolved my download issues. I think it is my internet provider. I was quickly able to download them from work.
Thanx Bob sir for awesome videos....
thanks a Lot SIR. Ur videos Helped me a lot!!
Thank you Bob for these Video! I love it!
Hey Bob , your style of teaching is amazing. I think words fall short of what you have delivered (Style, professionalism, attitude to teach. This is no flattery but having C# as free series is a blessing for all the folks who want to be programmers in the Microsoft realm, which usually cost $$$ outside especially in this economy.
Bob . One again you rock!
If you debugged the above message, there is a build error (haha) . Closing ")" braces missing after the word teach on line 3. Great way to teach troubleshooting.
@Neo:
I had to read that a couple of times to get the joke. Nice. 
I want to study the fundamental of c#, please tell the best book that I can simply understand the language.
Hi Bob, thanks a lot. I'm so excited about this series. I just wish there was an option to download all the videos at once. For I assure you... They will be eventually. ^_^
Hey Bob, I am running Visual Studio Express 2012 for Windows 8. I am not sure how to start a new console application. I can't see any option for it when I click file>new project. Thanks for your help!
Reviewed some of the comments. Have a terrible time actually seeing what he is typing. On my ipad I can scrub but can't see what Bob is typing. On my computer, pretty new, widescreen, I also can't see what Bob is typing, even almost when its in fullscreen! Is there anywhere to go to see these videos larger. Seems like a great series....
thanks alot bob ...
can you upload series of sql server !!
i am keen to learn that topic !!
I just would like to say some words in my own language.
Allah razı olsun...
I have been trying to teach myself C-languages for a while now and these videos have been a great help to me in regards to following along. Thank you all very much for giving your knowledge to others. Five year plan; HERE I COME!
thanks Bob :)
challenging
Yes hello Bob I know you are one of those people that were abducted by the aliens and they injected you with super intelligence and now you are trying to teach us how to say “hello aliens” and I am trying hard to learn the language. I think I just need to give my programing more memory. But seriously thank you for your generosity this is helping me with my college courses
Hi Ian,
I was running into the same problem in trying to follow along. You will need to download Visual Studio Express 2012 for Windows Desktop. At which point, the Console Application template will become available under Visual C#. Hope that helps.
This is a wonderful resource, the fact that it is free and you still answer questions is astounding to me! You sir are a good man. I believe my machine just might be possessed, here is my code and the resulting error message I received:
------------
C:\Windows\Microsoft.NET\Framework\v4.0.30319>csc /t:exe /out:c:\HelloWorld\Hell
oWorld.exe c:\HelloWorld\HelloWorld.cs
Microsoft (R) Visual C# 2010 Complier version 4.0.30319.1
Copyright (C) Microsoft Corporation. All rights reserved.
c:\HelloWorld\HelloWorld.cs(5,30): error CS1010: Newline in constant
C:\Windows\Microsoft.NET\Framework\v4.0.30319>
-----------
I'm running Windows 7 on an Alien Desktop. Continuing on with the tutorial, many thanks!!
Found it.... it was a missing " in the HelloWorld.cs
:)
Thank you for the great videos. I just started wish me a good luck.
Regards,
Sen
thank you sir , this is best video .
I am curious if Bob is still around. He hasn't been on for a long time now, may be since September 2012???
He thanks for the video series. I'm a total beginner and trying to learn c#. I have visual studio express 2012 for windows8 and blend. What I've discovered is that I can't make console apps in this IDE. Is there an easy way for me to translate your lessons into this environment?
What it would be nice if this new lovely video player will stay full screen when you click on another app. I have 2 monitors so trying to be multitasking and learn in the process. I hope somebody from Channel 9 will catch this. Best regards to all and yes a nice and good show. Planning to watch them all and redirect juniors to this videos. Thx.
nice! I start the videos yesterday and I'm using visual studio express 2012, all is ok with the first video...
sir i have visual studio 2012 express edition ..should i have to install the previous version for learning of c# because their isnt any console application in the newer version of visual studio
sir i have visual studio 2012 express edition ..should i have to install the previous version for learning of c# because their isnt any console application in the newer version of visual studio
Hi Bob,
I use Windows 7 (like you), in the prompt I do get a error:
CS5001: program 'c:\HelloWorld\HelloWorld.exe' does not contain a static
'Main' method suitable for an entry point
How can I fix this?
Thanks in advance.
Regards,
Marcel
Hi Bob,
I use Windows 7 (like you), in the prompt I do get a error:
CS5001: program 'c:\HelloWorld\HelloWorld.exe' does not contain a static
'Main' method suitable for an entry point
How can I fix this?
Thanks in advance.
Regards,
Marcel
ok this wasn't supposed to happen but by refreshing the page (video stopped) my question got uploaded again.
Sorry. :)
Could anybody please help me with the cmd error?
Thnx.
Marcel
Okay.....solved it as Bob tells us 1million times check your writing...and I wrote 'main' instead of "Main"...Oh boy. Feel like an 3th grader.
Hi All,
I use Visual Studio 2012 Express for web and I cannot sellect "Console Application"???
Please don't tell me that I have to install an different vs of Visual Studio...:(
Marcel
@Marcel: Yep, you'll need Visual Studio 2012 Express for Windows Desktop (not web).
Bob, mentions it above;
In that Important Update post he also provides a link to Download Visual Studio 2012 Express for Windows Desktop
@gduncan411: Heard and read it...how could I miss that one...well....let's download.
This an tutorial not for web programming is it, is it still an good basis for learning C#?
Thnx
@mducrocq68: Yes, this is a great series to learn C#.
That said, there's a number of other great that are also web focused. You can see them all here, Channel 9 Content for Beginners
Remove this comment
Remove this thread
close