标题:C#类与数组————在其他的类如何调用main函数的数组问题
取消只看楼主
冷锋2048
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2015-10-27
结帖率:57.14%
已结贴  问题点数:20 回复次数:0 
C#类与数组————在其他的类如何调用main函数的数组问题
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication8
{
    public class Student
    {
        private string name;
        private int chengji;
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        public int Chengji
        {
            get { return chengji ; }
            set { chengji = value; }
        }
        public void cahxun()//通过输入学生姓名查找其成绩的方法
        {
            string s = Console.ReadLine();
            for (int i = 0; i < 35; i++)
            {
                if (s == s[i])//通过姓名数组的下标找到他的五门成绩
                {
                    for (int j = 0; j < 5; j++)
                    {
                        Console.WriteLine(stu[i, j]);
                    }
                }
            }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Student[] s = new Student[35];
            for (int i = 0; i < 35; i++)//记录姓名
            {
                s[i] = new Student();
                s[i].Name = Console.ReadLine();
            }
            Student [,] stu = new Student[35, 5];
            for (int n = 0; n < 35; n++)//记录35名学生的五门成绩
            {
                for (int m = 0; m < 5; m++)
                {
                    stu[n,m]=new Student ();
                    stu[n, m].Chengji = int.Parse(Console.ReadLine());
                }
            }
        }
    }
}
搜索更多相关主题的帖子: private public return 如何 
2016-04-21 12:51



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-463938-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 2.139974 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved