1、讲解了实验1中,利用Char.is***来进行判断字符类型。

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace MyProject
{
class Program
{
static void Main(string[] args)
{ Console.WriteLine("请输入一个字符");
int x = Console.Read();
char ch = (char)x;
string res = "";
if ( char.IsDigit(ch) )
{
res = "数字";
}
else if ( char.IsLower(ch) )
{
res = "小写字母";
}
else if ( char.IsUpper(ch) )
{
res = "大写字母";
}
else
{
res = "其他字符";
}
Console.WriteLine("{0} 是 {1}",ch,res);
}
}
}

判断字符类型

2、讲解了实验2中,利用Split分割字符数组,以及统计每一个字母的输出的次数。

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace MyProject
{
class Program
{
static void Main(string[] args)
{
string s = "If you ask me how much i love you!";
//利用了匿名数组,省略了实例化的过程.
string []str = s.Split(new char[] {',','.',' ',' '},StringSplitOptions.RemoveEmptyEntries); //获取数组的长度
int len = str.Length;
int Len = str.GetLength(); //两次转换,一次转化成大写字母,第二次转化成Char类型的数组.
char [] arr = s.ToUpper().ToCharArray();
int[] Cnt = new int[];
foreach (var item in arr )
{
if( char.IsUpper(item))
Cnt[item-'A']++;
} //输出对应字母的出现的次数
for (int i = ; i < ; i++ )
{
Console.WriteLine("{0} - {1}",(char)(i+'A') , Cnt[i]);
} }
}
}

3、讲解了C#中类的“属性”,“构造函数”,“override-Tostring”

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace MyProject
{
class Program
{
static void Main(string[] args)
{
Shape s = new Shape();
Console.WriteLine(s);
}
}
//通常写在调试类的下面
//这个类为: internal (内部的),只能在当前项目程序能使用.
class Shape
{
//类里面的 数据成员
//类型为:private,原因对成员进行封装,
// 不允许直接在类外部直接访问或修改.
private int weight;
private int height; //传统的Java: get/set方法
public void setWeight( int weight)
{
this.weight = weight;
}
public int getWeight()
{
return weight;
} //C#特有的"属性"
//注意: 1:属性一定是首字母大写!大写!大写!
// 2:只是对字段进行封装的方法 public int Weight
{
get { return weight; }
set { weight = value; }
} //匿名属性
public int NULL_P
{
get { return NULL_P; }
set { NULL_P = value; }
} //右键重构 数据成员的代码
public int Height { get => height; set => height = value; } //有参数的构造函数
public Shape ( int width , int height )
{
this.weight = width ;
this.height = height ;
}
//无参数的构造函数
public Shape() : this(, ) { } //返回面积
public int Area()
{
//这里直接 就是 数据成员的weight,height.
//这里和加了this. 是一样的.
return weight * height;
} public override string ToString()
{
//1、利用类ToString方法把数字转化为String
//return (weight * height).ToString(); //2、默认为 返回 "命名空间+类名" 的结构
//return base.ToString(); //3、利用string.Format()进行格式化
return String.Format("Area = {0}",weight*height);
}
}
}

类的基本操作

【C#】课堂知识点#3的更多相关文章

  1. 【C#】课堂知识点#2

    课堂上老师讲了几点,自己觉得挺重要的,记录下来 1.代码字体调大,方便调试 2.虚心请教,没有谁比谁厉害,不会就虚心多请教,baidu并不能解决所有问题.沟通交流也是一种能力 3.只有每行写对了,才继 ...

  2. C++ 大学课堂知识点总结

    一.从C到C++1.引用int b;int &a = b;//a是引用类型       定义的时候加&  表示引用   其余都是取地址  a是b别名 使用a和使用b是一样的  主要用于 ...

  3. 【C#】课堂知识点#4

    1.回顾类中基本结构. 成员分为: a.(数据成员) , b.(方法成员) 数据成员: 字段 方法成员:方法,构造函数,属性,索引器,运算符. 属性的作用: 对字段进行访问提供get,set方法. 类 ...

  4. 【C#】课堂知识点#1

    标准数字格式字符串 https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-string ...

  5. Html----开头

     Html开头 *<meta http-equiv='content-type' content='text/html;charset=utf-8'>*定义字符编码,这是必须有的 后另存为 ...

  6. python_06

    今日内容:注意: selenium驱动的浏览器是干净的,没有任何缓存. 1.selenium剩余用法 2.selenium万能登录破解 3.selenium爬取京东商品信息 4.破解极验滑动验证码 X ...

  7. OO_Unit4_Summary暨课程总结

    初始oo,有被往届传言给吓到:oo进行中,也的确有时会被作业困扰(debug到差点放弃):而oo即将结束的此刻,却又格外感慨这段oo历程. 一.单元架构设计 本单元任务是设计一个UML解析器,能够支持 ...

  8. 妙味课堂史上最全的javascript视频教程,前端开发人员必备知识点,新手易学,拔高必备!!!

    妙味课堂是北京妙味趣学信息技术有限公司旗下的IT前端培训品牌, 妙味课堂是一支独具特色的IT培训团队,妙味反对传统IT教育枯燥乏味的教学模式,妙味提供一种全新的快乐学习方法! 妙味js视教第一部分  ...

  9. 小D课堂 - 零基础入门SpringBoot2.X到实战_第1节零基础快速入门SpringBoot2.0_1、SpringBoot2.x课程介绍和高手系列知识点

    1 ======================1.零基础快速入门SpringBoot2.0 5节课 =========================== 1.SpringBoot2.x课程全套介绍 ...

随机推荐

  1. 软件工程实践2019第五次作业——结对编程的编程实现 version1.1

    1.链接 我的博客链接https://github.com/S031402112 结对同学的博客https://www.cnblogs.com/jiabingge/ 我们队创建的仓库的Github项目 ...

  2. C# ffmpeg 视频处理

    ffmpeg的官网:https://ffmpeg.org/ ffmpeg是一个强大的视频处理软件(控制台程序),可以通过C# 调用ffmpeg,并传入指令参数,即可实现视频的编辑. /// <s ...

  3. Cent0S 6.7直接在/etc/resolv.conf文件下修改DNS地址重启不生效问题【转】

    CentOS 6.7/Linux下设置IP地址 1:临时修改: 1.1:修改IP地址 # ifconfig eth0 192.168.2.104 1.2:修改网关地址 # route add defa ...

  4. 拒绝让Eclipse帮倒忙,解决其复制粘贴时把反斜杠变成双反斜杠的问题

    比如,你粘贴到字符串的文本是“C:\Users\horn1\Desktop”,结果变成了“C:\\Users\\horn1\\Desktop\\”,这还好,不会带来麻烦. 但是,比如你输入的是正则表达 ...

  5. C#利用反射获取实体类的主键名称或者获取实体类的值

    //获取主键的 PropertyInfo PropertyInfo pkProp = ).FirstOrDefault(); //主键名称 var keyName=pkProp.Name; //实体类 ...

  6. STL补充--set集合相等判断

    一:问题引出 #include <iostream> #include <map> #include <set> using namespace std; map& ...

  7. 【设备问题】罗技M590鼠标无法连接Macbook Pro问题解决

    问题现象 罗技蓝牙鼠标连接的时候一直显示连接中,但是一直连接不上. 解决方法 长按那个切换模式的按钮,重置下,再点击连接,显示能够连接成功.

  8. Linux记录-mysql服务管理shell实现

    #!/bin/bash menu() { echo "---欢迎使用mysql管理服务程序---" echo "# 1.启动服务" echo "# 2 ...

  9. 【432】COMP9024,Exercise9

    eulerianCycle.c What determines whether a graph is Eulerian or not? Write a C program that reads a g ...

  10. spring 使用Spring表达式(Spring EL)

    Spring还提供了更灵活的注入方式,那就是Spring表达式,实际上Spring EL远比以上注入方式强大,我们需要学习它.Spring EL拥有很多功能. 使用Bean的id来引用Bean. •调 ...