c# 第29节 类
2024-09-06 10:09:02
本节内容:
1:类是什么
2:声明类
3:类的使用
1:类是什么
2:声明类
在生产上的声明:如下操作 或者快捷操作 ctrl+shift+a 键
出现如下界面:
3:类的使用
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace cw
{
public enum gender //public 是为了让所有的类都可以使用
{
男,
女
}
public class Clerk
{ //
public string _name; //public是为了在静态方法中可以通过实例对象,使用
public gender _gerder;
public int _age; public void show()
{
Console.WriteLine("{0}是{1},{2}岁。",this._name,this._gerder,this._age); } }
}
cw 下的Clerk
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace cw
{
class Program
{
static void Main(string[] args)
{
//要想使用别的类要先实例化
Clerk zs = new Clerk();
zs._name = "张三";
zs._gerder = gender.男;
zs._age = ;
zs.show();
Console.ReadKey();
}
}
}
cw 下的Main所在类
输出:张三是男,34岁
最新文章
- 洛谷 P1182 数列分段Section II Label:贪心
- java 异步处理
- 对称密码-DES和3DES
- hdu4497 GCD and LCM ——素数分解+计数
- Java 线程池的原理与实现
- mrunit for wordcount demo
- 常州培训 day1 解题报告
- 使用第三方工具覆写Object中方法
- Android下实现tab页个人比较推崇的方法
- MongoDB开发学习(1)开天辟地,经典入门
- Android 之SparseArray<;E>;详解
- encode_json 会对给定的Perl的数据结构转换为一个UTF-8 encoded, binary string.
- 【一天一道LeetCode】#205. Isomorphic Strings
- centos 7创建ss服务(方式一)
- [leetcode]50. Pow(x, n)求幂
- Vue-条件渲染v-if与v-show
- BZOJ4785 ZJOI2017树状数组(概率+二维线段树)
- 泡泡一分钟:Automatic Parameter Tuning of Motion Planning Algorithms
- 可变数组(PLSQL)
- keras如何求分类问题中的准确率和召回率