www.xbdev.net
xbdev - software development
Saturday April 20, 2024
home | contact | Support | Programming.. With C# and .Net...
>>
     
 

Programming..

With C# and .Net...

 

A taste of C#

 

Well here we are... sitting there with your cup of coffee.. and of course reading this tutorial...  Now when I first started to learn C# myself, I just went out to the shops and purchased the windows publication of C# and .net ... and man it was a mistake.  I read it from front to back... but it spent more time teaching how to use the IDE and click and place objects, than it did on working with the C# syntax and getting the feel for the code. 

Once you can make that code stand up and bark, then you can start using fancy IDE's and wizards to generate your code :)

 

So with my first few tutorials, I'll be using the command prompt, and manually creating all my .cs files from scratch in either notepad or visual studio editor.  The command prompt...arggccc... I hear you shout..... DOS...ackkk....heheh... Well believe me, you'll thank me one day :)  It really helps you get the feel for the code... sort of like Luke Skywalker feeling the force in Star Wars.

 

Where do we begin?  How do we create C# programs in the command prompt? Well if you have VS.net installed, simply go to the command prompt, and type in csc.exe, and it will list your version of C# Compiler and allow you to check that its added to the windows system path.

 

Note:
 

C:>csc.exe

Microsoft (R) Visual C# .NET Compiler version 7.00.9466
for Microsoft (R) .NET Framework version 1.0.3705
Copyright (C) Microsoft Corporation 2001. All rights reserved.

fatal error CS2008: No inputs specified

 

 

Now hold on to your hat, as this is the point of no return... there is where we go in!  So top up your cup of coffee and get ready...ready to code!!!!

 

 

Open notepad, and create a blank file... then rename it to "simple.cs" ... and type in the following code:

 

Code: simple.cs

// simple.cs

 

class abc

{

      static void Main()

      {

            /* our program entry point*/

      }

}

 

And at the command prompt, type "C:>csc simple.cs" ... and it compiles and you now have a simple.exe .... OOoooo.....

 

Lets run it and see what happens..heheh.... I just can't help it...  <double click simple.exe> ..... acckkk...  that wasn't very exiting was it... a dos window popped up and closed.... Hmmm... well of course if it did anything more, like a game stared up, I would be very shocked... :)

 

But the point to note, is that Main() is our entry point.  This is where all our code begins and ends :)  REMEBER... C# is case sensitive, if you do "static void main()" it will not like it and give you an error message.

 

 

But we want more!... I need to see results... You must have heard of how C# is a .net language....or uses the .net library's.  So this is our next step... Where going to use this amazing library function called "WriteLine(...)" ... which will allow us to output to the screen...to the console screen I mean.  Graphics will come soon enough :)

 

 

{To Be Continued Soon}.

 

 

 

 

 

 

 

 

 
Advert (Support Website)

 
 Visitor:
Copyright (c) 2002-2024 xbdev.net - All rights reserved.
Designated articles, tutorials and software are the property of their respective owners.