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;//定义一个类的内容
}
}
{
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;//定义一个类的内容
}
}

浙公网安备 33010602011771号