zoukankan      html  css  js  c++  java
  • 第四次作业

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace ConsoleApplication5
    {
    class Program
    {
    static void Main(string[] args)
    {
    Employee[] empArray = new Employee[3];

    for (int i = 0; i < empArray.Length; i++)
    {
    empArray[i] = new Employee(i);//构造方法
    }
    for (int j = 0; j < empArray.Length; j++)
    {
    Console.WriteLine(empArray[j].ToString());
    }
    //第一部分


    Tester t = new Tester();
    t.DisplayVals(5, 6, 7, 8);//不需要生成数组,也可以传递需要的参数
    int[] explicitArray = new int[5] { 1, 2, 3, 4, 5 };
    t.DisplayVals(explicitArray);//第二部分

    const int rows = 4; const int columns = 3;
    int[,] rectangularArray = new int[rows, columns];//a个逗号就a+1维
    int[][] jaggedArray1 = new int[2][] { new int[5], new int[8] }; //a个[]代表a维,2代表两行,后面的5和8代表列数
    Console.WriteLine("{0}", jaggedArray1.Length);
    Console.ReadLine();
    }
    }
    }

    public class Employee
    {
    private int empID;
    public Employee(int empID)
    {
    this.empID = empID;
    }
    public override string ToString()
    {
    return empID.ToString();
    }

    }

    public class Tester
    {
    public void DisplayVals(params int[] intVals)
    {
    foreach (int i in intVals)
    {
    Console.WriteLine("DisplayVals {0}", i);
    }
    }
    }

  • 相关阅读:
    javascript第三方组件
    Object中的wait,notify,notifyAll基本使用(转)
    java基础
    RocketMQ
    java消息队列
    java消息队列怎么用
    java抽象类的使用
    java内部类理解使用
    随笔
    Tomcat服务器解析“GET /JavaWebDemo1/1.jsp HTTP/1.1”
  • 原文地址:https://www.cnblogs.com/zeromaiko/p/4396592.html
Copyright © 2011-2022 走看看