最全【Unityc#专题篇】—基础章题单实践_untiyc#实战(2),2024年最新我的阿里春招之路分享

img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

需要这份系统化资料的朋友,可以戳这里获取

🎶(B)一维数组


  • 实践经验

1.简单的if else逻辑语句可以换成三目运算符
2.foreach的灵活使用

在这里插入图片描述在这里插入图片描述

   static void Main(string[] args)
        {
            int[] A = new int[100];
            int[] B = new int[100];
            int[] C = new int[10];
            Random rand = new Random();
            //6.随机生成10个数
            for(int i = 0; i<A.Length;i++)
            {
                A[i] = 100;
                B[i] = 2 \* A[i];
                if(i<C.Length )
                {

                    C[i] = rand.Next(1,101);
                }
            }
            //7.数组中找出max,min,avge,all
            int max = C[0], min = C[0], avge = 0, all = 0;
            foreach (int i in C)
            {
                Console.Write(" " + i);
                all += i;
                if (i > max) max = i;
                if (i < min) min = i;
            }
            avge = all / C.Length; 
            Console.WriteLine("\n最大值{0},最小值{1},总和{2},平均值{3}\n",max,min,all,avge);
           //8.简单反转数组
           for( int i = 0; i<C.Length /2;i++)
            {
                int temp;
                temp = C[i];
                C[i] = C[C.Length -1-i];
                C[C.Length - 1 - i] = temp;
 
            }
            foreach (int i in C)
            {
                Console.Write(" " + i);
            }
         }
             //11.打印符号
            Console.WriteLine();
            string[] array = new string[25];    //简单的if 和else可以用三目运算符代替
            for(int i = 0; i< array .Length; i++)
            {
                array[i] = i % 2 == 0 ? "\*" : "&"; 
            }
            int Temp = 0;
            foreach( string i in array)
            {
                Temp++;
                Console.Write(" "+i);
                if (Temp % 5 == 0) Console.WriteLine();
            }



🎶(C)二维数组


  • 实践经验

1.array.length 此时代表的是全部元素数量
2.矩阵对角线规则 i == j的时候
3.矩阵上半部规则 j >= i 的时候

  static void Main(string[] args)
        {
            #region 第12题
            //const int Index = 100;
            //int[,] array = new int[Index, Index];
            //int x = 1;
            //Console.WriteLine("数组长度{0}", array.Length); //此时代表整个长度
            //for (int i = 0; i < Index; i++)
            //{
            // for (int j = 0; j < Index; j++)
            // array[i, j] = x++;
            //}
            //foreach (int i in array) Console.Write(" " + i);
            #endregion
            #region 第13题
            int[,] B = new int[4, 4];
            Random rand = new Random();
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    //让右上半部分为0
                    B[i, j] = j >= i ? 0 : rand.Next(1, 101);
                }
            }
            int temp = 1;
            foreach (int i in B)
            {
                Console.Write(" " + i);
                if (temp++ % 4 == 0) Console.WriteLine();
            }
            #endregion
            #region 第14题

            int[,] C = new int[3, 3];
            int All = 0;
            Random Rand = new Random();
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    C[i, j] = Rand.Next(1, 10);
                    if (i == j) All += C[i, j];
                }
            }
            Console.WriteLine();
            int t = 1;
            foreach (int i in C)
            {
                Console.Write(" " + i);
                if (t++ % 3 == 0) Console.WriteLine();
            }
            Console.WriteLine("对角线的和为{0}", All);
            #endregion
            #region 第15题
            int M,N;
            Random rrrand = new Random();
            try
            {
                Console.WriteLine("您想要要得到多少行多少列的矩阵呢");
              
                M = int.Parse(Console.ReadLine());
                N = int.Parse(Console.ReadLine());
                int[,] ros = new int[M, N];
                for (int i = 0; i < M; i++)
                {
                    for (int j = 0; j < N; j++)
                    {
                        //将下标为1的行或者列全部为1
                        ros[i, j] = i == 1 || j == 1 ? 1 : rrrand.Next(0, 2);
                    }
                }
                Console.WriteLine();
                int q = 1;
                foreach (int i in ros)
                {
                    Console.Write(" " + i);
                    if (q++ % N == 0) Console.WriteLine();
                }
             
            }
          
          catch
            {
                Console.WriteLine("请输入整形数字");
            }
            #endregion

在这里插入图片描述


🎶(D)值,引用类型存储上的区别


  • 实践经验

1.F9断点调试和F10向下调式
2.数组和string空间开辟和引用的关系

  • 值类型的实例化
    在这里插入图片描述
  • 引用类型的实例化
    在这里插入图片描述

在这里插入图片描述

  • 特殊引用类型的实例化
    在这里插入图片描述

🎶(E)函数的使用


  • 实践经验

1三目运算符的便捷性-简化和可观化代码
2.三行注释的运用
在这里插入图片描述


    /// <summary >
    /// 函数的运用
    /// </summary>
    class Program
    {
        const float Pi = 3.1415f;
        /// <summary>
        /// 返回最大值
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
         public int MAX(int a , int b) 
        {
            return a > b ? a : b;
        }
        /// <summary>
        /// 计算圆面积和周长
        /// </summary>
        /// <param name="r"></param>
        public void Circrl( int r)
        {
            Console.WriteLine("圆的面积为{0},周长为{1}", Pi \* r \* r, 2 \* Pi \* r);
        }
        /// <summary>
        /// 数组的基本操作
        /// </summary>
        /// <param name="a"></param>
        public void Array(int [] a)
        {
            int max, min, all= 0;
            max = min = a[0];
            foreach(int i in a)
            {
                max = i > max ? i : max;
                min = i < min ? i : min;
                all += i;
            }
            Console.WriteLine("数组的最大值为{0},最小值为{1},总和为{2},平均值为{3}", max, min, all, all / a.Length);
        }
        /// <summary>
        /// 判断质数
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        public bool ZhiShu( int x )
        {
            for (int i = 2; i < x; i++)
            {
                return i % 2 == 0 ? false : true;
            }
            return true;
        }
        /// <summary>
        /// 判断是否是闰年
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        public bool RYear( int x )
        {
            return x % 400 == 0 || (x % 4 == 0 && x % 100 != 0) ? true : false;
        }
        static void Main(string[] args)
        {
            Program text = new Program();
            text.MAX(5, 8);
            text.Circrl(2);
            text.Array(new int[] { 1, 2, 3, 4, 5 });
            text.ZhiShu(5);
            text.RYear(2023);

        }


🎶(F)ref和out


  • 实践经验

1.ref和out的作用是什么——参数变成引用的你变我也变
2.ref和out的区别是什么

ref传之前不用初始化,out需要
ref传之后要在函数中被赋值,out不用

  /// <summary>
    /// ref out的区别在于,ref修饰的传参不用经过初始化但是out需要
    /// </summary>
    class Loading
    {
       private string acount = "L24158";
       private string SSSecret ="qbz123";
       public bool Message(  string a , string b, ref string c)
        {
            if(a!=acount)
            {
                c = "用户名错误";
                return false;
            }
             if(b!= secret)
            {
                c = "密码错误";
                return false;
            }
            return true;
        }
        static void Main(string[] args)
        {
            Loading text = new Loading();
            Console.WriteLine("请输入用户名:");
            string A = Console.ReadLine();
            Console.WriteLine("请输入密码:");
            string B = Console.ReadLine();
            string C = "";
           text. Message( A, B,ref C);
            Console.WriteLine(C);

        }


🎶(G)params


  • 实践经验

1.要考虑数组为空时的条件
2.params的特点

在这里插入图片描述

      #region 28和29,param加长参数的考察
        public void Result(params int [] arrary)
        {

            int all = 0, avage = 0 , dou = 0, sin = 0;
            //要考虑全面还需判断是否为空
            if(arrary == null) { Console.WriteLine("未有参数传递进去!"); }
            for (int i = 0; i < arrary.Length; i++)
            {
                all +=arrary[i];
            }
            avage = all / arrary.Length;
            Console.WriteLine("总值为{0},平均值为{1}",all,avage);
            foreach (var item in arrary)
            {
                if (item % 2 == 0) dou += item;
                else sin += item;
            }
            Console.WriteLine("偶数和为{0}。奇数和为{1}", dou, sin);
        }

        #endregion


🎶(H)重载


  • 实践经验

1.掌握重载的特点
不考虑返回值
类型一致,数量,和参数类型不一致
在这里插入图片描述

       #region 28和29,param加长参数的考察
        public void Result(params int [] arrary)
        {

            int all = 0, avage = 0 , dou = 0, sin = 0;
            //要考虑全面还需判断是否为空
            if(arrary == null) { Console.WriteLine("未有参数传递进去!"); }
            for (int i = 0; i < arrary.Length; i++)
            {
                all +=arrary[i];
            }
            avage = all / arrary.Length;
            Console.WriteLine("总值为{0},平均值为{1}",all,avage);
            foreach (var item in arrary)
            {
                if (item % 2 == 0) dou += item;
                else sin += item;
            }
            Console.WriteLine("偶数和为{0}。奇数和为{1}", dou, sin);
        }

        #endregion
        /// <summary>
        /// 考察重载的特点
        /// </summary>
        public float Result( float A ,float B)
        {
            return A > B ? A : B;
        }
        static void Main(string[] args)
        {
            int a = 1, b = 2, c = 3, d = 4;
            Program text = new Program();
            text.Result(a, b, c, d);
        }
    }


🎶(I)递归


  • 实践经验

1.退出条件
2.递归条件
3.有返回值就代表结束了,不用再添加判断语句

在这里插入图片描述

   #region 32~36递归题目
        public int all;
        /// <summary>
        /// 32
        /// </summary>
        /// <param name="i"></param>
        public void Digui(int i)
        {
            if (i == 11) return; //结束条件
            Console.Write(i+" ");
            Digui(++i);           //递归条件
        }
        /// <summary>
        /// 33
        /// </summary>
        /// <param name="x"></param>
        public int CC(int w)
        {
            if (w == 0) return 1;  //结束条件
            return  w\* CC(w - 1);//递归条件
        }
        public int  Mulitiplay(int x)
        {
            if(x == 1) return CC(1);   //结束条件
            return CC(x)+Mulitiplay(x-1); //递归条件
           
        }

        /// <summary>
        /// 35
        /// </summary>
        /// <param name="Alenth"></param>
        /// <param name="day"></param>
        /// <returns></returns>
        public float Length(float Alenth,int day)
        {
            if(day == 10) return Alenth;   //结束条件

            return  Length(Alenth / 2, ++day); //递归条件
        }   
        /// <summary>
        /// 36
        /// </summary>
        /// <param name="M"></param>
        public void Print(int M)
        {
            if (M > 200) return;//结束条件

            Console.Write(" " + M); Print(++M); //递归条件
        }
   
        static void Main(string[] args)
        {
            Program text = new Program();
            text.Digui(0);
            Console.WriteLine("\n"+text.Mulitiplay(5));
            Console.WriteLine("\n" + text.all);
            Console.WriteLine(text.Length(100f,1));
            text.Print(1);
            Console.WriteLine("\n"+text.CC(5));
           
        }
        #endregion


🎶(J)结构体


  • 实践经验

1.结构体和类的区别(初始化,内存类型,自定义自身)
2.什么时候用结构体什么时候用累(运行效率上看)
在这里插入图片描述

   #region 37题
        struct Student
        {
            string name;
            string sex;
            int age;
            string sclass;
            string majoy;
          public  Student(string name ,string sex ,int age ,string  sclass ,string majoy)
                {
                this.name = name;
                this.sex = sex;
                this.age = age;
                this.sclass = sclass;
                this.majoy = majoy;
                }
          public void Print()
            {
                Console.WriteLine("学生姓名为{0}\n性别为{1}\n年龄为{2}\n班级为{3}\n专业为{4}", name, sex, age, sclass, majoy);
            }
        }
        static void Main(string[] args)
        {
            Student SS = new Student("张三","男",18,"一班","信息工程");
            Student MM = new Student("李四", "女", 19, "二班", "信息工程");
            SS.Print();

        }
        #endregion
        #region 41题
        //struct S\_SmallBoss 
        //{
        // public string name ;
        // public int damage; 


![img](https://img-blog.csdnimg.cn/img_convert/2f811e2ddabd8307ad0e16a488322958.png)
![img](https://img-blog.csdnimg.cn/img_convert/87bed5a6d929dbc9b51718473a961da9.png)

**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/forums/4f45ff00ff254613a03fab5e56a57acb)**


**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

      Student SS = new Student("张三","男",18,"一班","信息工程");
            Student MM = new Student("李四", "女", 19, "二班", "信息工程");
            SS.Print();

        }
        #endregion
        #region 41题
        //struct S\_SmallBoss 
        //{
        // public string name ;
        // public int damage; 


[外链图片转存中...(img-cUknxjcL-1715472911194)]
[外链图片转存中...(img-s5CY5MDi-1715472911195)]

**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/forums/4f45ff00ff254613a03fab5e56a57acb)**


**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值