1_静态变量的调用

C#平台:控制台应用程序

程序及注释:

using System;
namespace ConsoleApp1
{
    class Program
    {
        static string StuName = "徐菲菲";
        static void Main(string[] args)
        {
            int Age = Student.stuAge;//调用类中的内容
            Console.WriteLine("{0}今年{1}岁了",StuName,Age);
            Console.ReadKey();
        }
    }
    class Student  //创建一个类
    {
        public static int stuAge =12;//定义一个类的内容
    }
}

 

posted @ 2020-09-17 15:26  siha123  阅读(248)  评论(0)    收藏  举报