- 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
- 《GB/T 21714.4-2026雷电防护 第4部分:建筑物内电气和电子系统》.pdf
- 中国国家标准 GB/T 21714.4-2026雷电防护 第4部分:建筑物内电气和电子系统.pdf
- GB/T 21714.4-2026雷电防护 第4部分:建筑物内电气和电子系统.pdf
- 中国国家标准 GB/T 21714.3-2026雷电防护 第3部分:建筑物的物理损害和生命危险.pdf
- 《GB/T 21714.3-2026雷电防护 第3部分:建筑物的物理损害和生命危险》.pdf
- GB/T 21714.3-2026雷电防护 第3部分:建筑物的物理损害和生命危险.pdf
- GB/Z 47790.21-2026电测量 付费系统 第21部分:标准化框架.pdf
- 中国国家标准 GB/Z 47790.21-2026电测量 付费系统 第21部分:标准化框架.pdf
- 《GB/Z 47790.21-2026电测量 付费系统 第21部分:标准化框架》.pdf
- 《GB/T 32151.56-2026温室气体排放核算与报告要求 第56部分:制冷空调设备生产企业》.pdf
最近下载
- 2026秋学期小学苏教版数学四年级上册教学计划含进度表.docx VIP
- 新版西师版六年级上册数学全册单元教材分析.docx VIP
- 不同型式搅拌桨在黄原胶溶液中混合性能的分析-analysis of mixing performance of different types of paddles in xanthan gum solution.docx VIP
- 2025年大学《海洋资源与环境-海洋资源学》考试参考题库及答案解析.docx VIP
- 2026年设备监理师《设备监理基础知识和相关法规》考试真题(后附答案解析).docx VIP
- Interroll(英特诺物流机械)驱动控制DriveControl 20 54 2048操作说明书.pdf
- 工程荷载与可靠度设计原理4 风荷载.pptx VIP
- 4103-2023年钢制管道焊接验收标准.docx
- 新课改下体育大单元教学设计与实践路径.docx VIP
- CN120219120A 基于教育知识图谱的教学方案多维动态评价方法及系统 (北京师范大学).pdf VIP
原创力文档

文档评论(0)