C#类中static变量用法分析

这篇文章主要介绍了C#类中static变量用法,实例分析了static变量使用技巧与相关注意事项,需要的朋友可以参考下

本文实例讲述了C#类中static变量用法。分享给大家供大家参考。具体分析如下:

先来看一段代码:

复制代码 代码如下:
using System;
namespace Param
{
class Class1
{
static int i = getNum();
int j = getNum();
static int num = 1;
static int getNum()
{
return num;
}
[STAThread]
static void Main(string[] args)
{
Console.WriteLine(string.Format("i={0}",i));

Console.WriteLine(string.Format("j={0}",new Class1().j));

Console.Read();

}
}
}

以上就是C#类中static变量用法分析的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » 其他教程