C # Foundations (+ Structure Method)

structure:

  Role: You can help us one time declared a number of different variables

:( grammar class method name with the same name, there is no return type of statement before the method name, return statement can not be used to return a value)

  

   public static structure name

  {

    public variable 1; public int _age;

    public variable 2; public string _name;

    public variable 3; public char _gender;    

  }

 

  Main()

  {

    Name structure definition name;

    Definition 1 = variable name **; Define names _age = 20;

    . = 2 ** variable definition name; Define names _name = 20;

    Define variable name = 3 **; Define names _gender = 20;

****************************************************************************************

    Console.WriteLine ( "My name is {}, {} I am old, I was born {}" definition name ._name, definition name ._age, define the name, _gender);

    Console.ReadKey();

  }

***********************************************************************************************************************

The method ( function ):

  Function is a pair of code reuse mechanism.

  Function syntax:

  public static method return value name ([parameter list])

  { 

         Method body; 

  }  

   static: Static

         if (a > max)

    { 

         return a;

    }else {

    return b;  

  }

 

Guess you like

Origin www.cnblogs.com/leiminghui/p/10958811.html