Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C# Basics I/O Strings and Integers
08-14-2009, 10:56 PM (This post was last modified: 08-14-2009 10:56 PM by Back_track.)
Post: #1
C# Basics I/O Strings and Integers
I made this tutorial on C# for someone who has little or no experience in the world of programming so here it is my next lesson Loops
Code:
using System;
using System.Collections.Generic; // uses
using System.Text;

namespace Variables // your programs namespace
{
    class Basics // a single class
    {
        static void Main(string[] args)// iniates the program similiar to int main() in C++
        {
            string str;// declares str as a string variable
            str = " This is a string variable!";// tells the computer that str( our variable) equals the following Text in quotes
            Console.WriteLine("{0}   That was our string variable printing out ", str);// the {0} stands for a place of a variable similiar to %d in C(difference is that %d is for a number only)
            //^ continued then spews out some text ends the quotes then uses the coma to tell which variable has been assigned to {0}
            Console.ReadLine();// just ignore that for now i used it to keep the console from flashing away it will be explained later
            Console.Clear();//clears the text on the console
            Console.WriteLine("  Enter in a number this will show input: ");// Prompts the user to enter in a number
            int num = Convert.ToInt32(Console.ReadLine());// iniates an integer named num and tells the compiler that it equals Console.ReadLine() but If you try just making int int num = Console.ReadLine()
            //^continued : you'll get an error that Console.ReadLine() is a string a num is an integer to solvr this problem you'll have to do some conversion C# has already made something named Convert.To()
            //^continued : so you want to make Console.Readline() an integer like you variable so simple Convert.ToInt32(Console.ReadLine()) so now you can enter a number
            Console.WriteLine(" {0} that was our integer printing to the console screen", num);//this one is self-explanatory if you understood everything above declares where the variable will be spews some text then tell which variable to use
            Console.ReadLine();//Again this is just used to keep Console From going away
            /* Done with Basics now move to Loops */
            


        }

      
            
        }
            



                


            }
I added the rar with all the files just incase the copy/paste didn't come out correctly


Attached File(s)
.rar  Basics1.rar (Size: 33.74 KB / Downloads: 4)

"Character is determined more by the lack of certain experiences than by those one has had."
Friedrich Nietzsche
Visit this user's website Find all posts by this user
Quote this message in a reply
08-14-2009, 11:16 PM
Post: #2
RE: C# Basics I/O Strings and Integers
Yah, i advise people to download the rar file as the copy/paste didn't turn out too well!

It will be ALOT easier to read in the C# Compiler!
Find all posts by this user
Quote this message in a reply
08-15-2009, 12:23 AM
Post: #3
RE: C# Basics I/O Strings and Integers
I have read this, though i know it, i think it is great !
Back_track what do you think of making a huge tut about c#, or you can post here parts of lessons and then we
can make like a HTML version of it and post it in /csharp dir or something like that !

"I dont know with what weapons World War 3 will be fought with, but i know World War 4 will be fought with stones and sticks" - Albert Einstein
Visit this user's website Find all posts by this user
Quote this message in a reply
08-15-2009, 06:05 AM
Post: #4
RE: C# Basics I/O Strings and Integers
(08-15-2009 12:23 AM)drdebcol Wrote:  I have read this, though i know it, i think it is great !
Back_track what do you think of making a huge tut about c#, or you can post here parts of lessons and then we
can make like a HTML version of it and post it in /csharp dir or something like that !

Yeah that sounds like a great idea! and it will surely help me with learning c#

"Character is determined more by the lack of certain experiences than by those one has had."
Friedrich Nietzsche
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme: