- 42
- 0
- 约3.4万字
- 约 38页
- 2015-09-25 发布于重庆
- 举报
c基础常见面试题
C#基础概念二十五问
答:
静态变量使用 static 修饰符进行声明,在类被实例化时创建,通过类进行访问
不带有 static 修饰符声明的变量称做非静态变量,在对象被实例化时创建,通过对象进行访问
一个类的所有实例的同一静态变量都是同一个值,同一个类的不同实例的同一非静态变量可以是不同的值
静态函数的实现里不能使用非静态成员,如非静态变量、非静态函数等
示例:
using System;
using System.Collections.Generic;
using System.Text;
namespace Example01
{
class Program
{
class Class1
{
public static String staticStr = Class;
public String notstaticStr = Obj;
}
static void Main(string[] args)
{
//静态变量通过类进行访问,该类所有实例的同一静态变量都是同一个值
Console.WriteLine(Class1s staticStr: {0}, Class1.staticStr);
Class1 tmpObj1 = new Class1();
tmpObj1.notstaticStr = tmpObj1;
Class1 tmpObj2 = new Cla
您可能关注的文档
- CHAOS直升机空战(新年版)安卓版 破解版 攻略.doc
- Chapter Four Designing Pricing Strategies定价策略.doc
- Characterising, Explaining, and Exploiting the Approximate Nature of StaticAnalysis through.pdf
- Characteristics of Aldoped ZnO thin films obtained by ultrasonic spray pyrolysis effects of Al dopi.pdf
- Characteristics of Microencapsulated Nutritional Oil for Infant Formula Food.pdf
- Characteristics of high efficiency dyesensitized solar cells.pdf
- Characteristics of solitary waves on a running film down an inclined plane under an electrostatic.pdf
- Characterization and Uncertainty Analysis of a Reference Pressure Measurement System for Wi.pdf
- Characterizing and Modeling the Dynamics of Online Popularity.pdf
- Characters Analysis of Oliver Twist of Charles Dickens.doc
最近下载
- DJI大疆御 Mavic Mini说明书 用户手册.pdf
- 2026年上海市崇明区初三下学期二模物理卷和参考答案及评分标准.docx VIP
- 2026江苏有线连云港分公司招聘4人笔试历年常考点试题专练附带答案详解.docx VIP
- 2026年高新技术企业研发项目立项申请书.docx VIP
- 国家义务教育质量监测八年级艺术学科抽测.doc VIP
- 危险化学品生产使用企业老旧装置安全风险评估报告.docx
- 大猫分级阅读4级Sounds.pdf VIP
- DCAP-3001馈出变监控保护装置使用说明书(V2.0).pdf VIP
- 国家义务教育质量监测八年级美术模拟卷.doc VIP
- 骨科重点总结.pdf VIP
原创力文档

文档评论(0)