Tony's C # first lesson

xiaoxiao2021-03-06  43

/ * * This is Tony's first C # program, continue to work hard! * /// Defines the namespace (my understanding: There will be the sub-name of the same name in different namespaces, just like the files of the same name in different directories, distinguishable by namespace; class example // Class is the basic unit of C # packages, in C #, all activities of the program occur in the class {public static void main () // static keyword allows the main () method to be called before his class object is created, program When you start running, you will call main {console.writeline ("a Simple C # Program!"); // WriteLine method is a member of the Console class show1 (); // C # All statements are ended in a semicolon, of course, class It seems that there is no need, there is {}, it doesn't have a semicolire with aaa.ashow (); example1.show2 ();} private static void show1 () // void Description This method does not return value {Console.writeline ("Show1: a new Line! ");} public class aaa {public static void ashow () {console.writeline (" Class in class! ");}}}

Class Example1 {public static void show2 () // This will prompt the SHOW2 method to limit {Console.WriteLine ("Example1 Show2: New Line!"); example.AAA.ASHOW (); / * * I tried to call the AAA class in the Example class (above statement), but unsuccessful, error, error restriction * I found only "Class" when defining the AAA class in Example AAA, later, I added "public" in front, so that I can call in the example1 class *. (Bingo) * The original class is called to be marked as: "public", if not marked, is considered to be private. * / Console.writeline ("public class in class, congration !!!");}} // Note: 1. C # program is case sensitive (very important); // 2, the C # program is from main () There is only one main () in the program. // If the error writes main, the compiler can compile the class that does not contain the main () method, but the compile time prompts an error message: No procedure Point /// Current question: What is the reference to do? Quote should be in order to use "others" things:) //

转载请注明原文地址:https://www.9cbs.com/read-67168.html

New Post(0)