Portfolio

Wednesday, May 23, 2012

My take on Programming

In the past few months I have been learning
tons off C# and I think I have the Syntax
fully grasped.I have read lots of books
and what I have come to learn is that there
is only one sure way for a true begin to get
As much as you can as fast as you can and
that to learn they to things and get them in
your head and grasp them as fast as you
can.

Number 1: everything in C# is A class and a class is a object
 Class == object
Number 2: if you know everything in a class template than you pretty much know 90% C# syntax
class template == 90% C# syntax
so this is what A class looks like and what you need to know



public class Person
{
    // Fields are just variables for a class make sure you learn what these are
    public string name;

    // Constructor learn what this is 
    public Person()
    {
        name = "unknown";
    }

    // Method learn what methods are and you will no about 90% of the syntax trust me
    public void SetName(string newName)
    {
        name = newName;
    }
}

2 comments:

  1. You also need to know what structs are and when to use a class and when to use a struct

    and the example method you give, is a typical C / C++ style, since we are using c# you should use the auto property syntax:

    public TYPE NAME { (modifier)get; (modifier)set;}

    examle:

    public int Age {get;set;};
    (get and set are by default public)
    you can use modifiers as well:

    public int Age {get; private set};


    and if you need to perform some more task you can use this:

    int _age;

    public int Age {get { return value;} ; set { if(value<0)
    {
    //Invalid, perform your code
    }else
    _age = value;
    }


    this is out of my head so it could have some syntax errors

    ReplyDelete
  2. // Method learn what methods are and you will no about 90% of the syntax trust me

    syntax is something different...
    "wiki": the syntax of a programming language is the set of rules that define the combinations of symbols that are considered to be correctly structured programs in that language.



    you are talking about Methodology/Paradigms

    ReplyDelete