12430人加入学习
(21人评价)
C#编程-第二季-面向对象-宇宙最简单2021最新版

制作完成于2021-10月20日 使用VS2019

价格 免费

除了字符串,其他都是值类型

 引用类型 只有字符串 数组 类 需要两段内存

 

 

[展开全文]

字符串存储在静态存储区

引用类型 保存一个 

 

 

[展开全文]

内存 中

堆 类似仓库

栈 类似

 

 

[展开全文]

public int Age {get;set;}

var 匿名类型 初始化什么类型就是什么lei'x

 

 

 

[展开全文]

属性为C#提供的方便读取和修改字段的格式

 

[展开全文]
衡心 · 2024-01-05 · 017-属性 0

构造函数就是用来构造对象的

 构造函数必须与类的名字相同

不需要返回类型 构造函数 

在new的时候就会调用

会选择匹配的构造函数

 

 

[展开全文]

public void Run(){

}

public void Stop(){

}

public float length(){

}

[展开全文]

创建对象

结构体不需要new

类需要new

 

 

[展开全文]

try{里面放可能出错的代码}

catch(FormatException e)

{

console.writeLine("")

n1 = convert.toint32(console.readline)

n2 = convert.toint32(console.readline)

}

 

[展开全文]

每一个类都是使用单独的文件来保存的

[展开全文]

class MyList<T>

{

  private T[] data = new T[0]; //data null

  //引用类型 new

  //MyClass mc;

}

[展开全文]

class ClassA<T>

{

  private T a;

  private T b;

  public ClassA(T a , T b)

  {

    this.a = a;

    this.b = b;

  }

  public string GetSum()

  {

  dynamic num1 = a;

  dynamic num2 = b;

  }

}

[展开全文]

class Program
{
    static void ShowList(List<int> list)
    {
        foreach (int temp in list)
        {
            Console.Write(temp + " ");
        }
        Console.WriteLine();
    }
    static void Main(string[] args)
    {
        List<int> list = new List<int>() { 56, 23, 894, 32, 5623, 32,4573 };

        //Console.WriteLine(list.Capacity);
        //list.Add(800);

        //Console.WriteLine(list[2]);

        //list.Insert(3, 800);


        //list.Remove(32);
        //ShowList(list);

        //list.RemoveAt(2);
        //ShowList(list);

        //增  删 改 查

        //Console.WriteLine(list.IndexOf(320));
        //Console.WriteLine(list.LastIndexOf(32));

        list.Sort();
        ShowList(list);

    }
}

[展开全文]

class Program

{

static viod Main(string[] args)

 {

 List<int> list = new List<int>() {321,654 987};

  list.Add(900);

  list.Add(6732);

 

  Console.Writeline(list[3]);

  list.Count;

  }

}

[展开全文]

class Program
{
    static void Main(string[] args)
    {
      StudentSt stu1 = new StudentSt(18, "小芳");
        StudentSt stu2 = new StudentSt(25, "小刚");

        stu2 = stu1;

        stu1.age = 30;
        stu1.name = "费伦";

        Console.WriteLine(stu2.age);
        Console.WriteLine(stu2.name);
    }
}

struct StudentSt
{
    public int age;
    public string name;

    public StudentSt(int age,string name)
    {
        this.age = age;
        this.name = name;
    }
}

[展开全文]

using System;

using System.Collections.Generic;

using System.Text;

 

namespace _09_抽象类

{

    public abstract class Enemy

    {

        private int hp;

        private int speed;

 

        public void Move()

        {

            Console.WriteLine("Move");

        }

        public abstract void Attack();

 

    }

}

[展开全文]

1、编写健壮性强的代码

[展开全文]

授课教师

问问题加入A计划,有专门负责答疑的老师哦!!!

课程特色

下载资料(1)
视频(60)