How to understand the code

Hi, I am very new to the visual C# express and I need help. I am completely lost on understanding the code and what it means. For the example I followed I put the code in "Private void" and I have no idea what this means. can any one point me in the right direction or have a good tutorial I can follow.

Answer this question

How to understand the code

  • Mitch84095

    Hi,

    void means that the method does not return a value, for example if you want to print something to a console window you might have a function like:

    void Print(string text)

    {

    Console.WriteLine(text);

    }

    However sometimes you want a value to be returned from a method i.e.

    double CalculateTax(double amountEarned)

    {

    return amountEarned * 0.3;

    }

    The "private" keyword means that the method cannot be called by any code that is not declared inside a class i.e.

    class MyClass

    {

    private void Foo()

    {

    }

    public void Bar()

    {

    }

    }

    void main()

    {

    MyClass x = new MyClass();

    //this is okay

    x.Bar();

    //this is not allowed

    x.Foo();

    }

    If I was you I would go and buy a beginners programming book in C#, search amazon they have lots of good ones, so that you learn the basics of programming.

    Mark.



  • How to understand the code