Thread: question compiling simple code

  1. #1
    Registered User
    Join Date
    Mar 2019
    Posts
    5

    question compiling simple code

    insert
    Code:
    using System;
    
    namespace Wrox
    {
        public class MyFirstClass
        {
            static void Main()
            {
                Console.WriteLine("Hello from Wrox.");
                Console.ReadLine();
                return;
            }
        }
    }

    I am told to compile this code using a txt editor saving it as a CS extension.

    Having some confusion compiling this to turn it into a EXE file.

    The book i am using says

    "You can compile this program by simply running the C# command line compiler (csc.exe) against the source file like this :

    csc first.cs

    It looks like from my understanding that i need to have visual studio installed to even changed this code into an EXE file. The book seems not to clarify this.

    Also from my noobie ness i tried to compile this in codeblocks but it wont work. Im guessing Codeblocks wont support C# ?

    Also tried compiling this on code blocks does codeblocks not support C#?

    Any help appreciated.
    Last edited by gabeperron; 03-24-2019 at 12:13 AM.

  2. #2
    Registered User
    Join Date
    Mar 2019
    Posts
    5
    to further clarify i do not have visual studio at the moment i can get it sure... but at the moment i have codeblocks on my pc . thanks.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Well code blocks is an Integrated Development Environment (IDE).
    It's a fancy term for what is basically a text editor, with hooks that allows it to run compilers, debuggers, help systems.

    By itself, code blocks doesn't even come with a compiler.

    Even when do get a toolset with code blocks, it is the MinGW GCC package for compiling C and C++ programs.

    So in short, yes you can use code blocks to edit your .cs files.
    But you need to download the 'csc' tools from Microsoft.

    But you might find it more convenient to just grab the whole visual studio package anyway, as everything will be configured out of the box.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. very very simple code (struct question)
    By tt29 in forum C Programming
    Replies: 1
    Last Post: 04-03-2011, 10:33 PM
  2. Simple question, trying to understand this code...
    By matthayzon89 in forum C Programming
    Replies: 11
    Last Post: 03-23-2010, 01:04 PM
  3. simple code question
    By potatopuff in forum C Programming
    Replies: 7
    Last Post: 07-15-2008, 01:31 AM
  4. Problem compiling simple code examples
    By Wintersun in forum Windows Programming
    Replies: 8
    Last Post: 08-14-2007, 10:30 AM
  5. Simple Compiling question ...
    By hypertension in forum C++ Programming
    Replies: 2
    Last Post: 02-16-2003, 01:02 PM

Tags for this Thread