日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > C# >内容正文

C#

C#源代码—姓名 请输入老师的编号、姓名、职称和部门

發布時間:2024/3/26 C# 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C#源代码—姓名 请输入老师的编号、姓名、职称和部门 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
靜態成員 ?性別姓名?
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;namespace _3._3 {public partial class Form1 : Form{public Form1(){InitializeComponent();}public enum Gender { 男, 女 };public class person{private static int males;private static int females;public string name;public Gender sex;public int age;public person(string name, Gender sex, int age){this.name = name;this.sex = sex;this.age = age;if (sex == Gender.男)males++;if (sex == Gender.女)females++;}public static int Numbermales(){return males;}public static int Numberfemales(){return females;}}private void Form1_Load(object sender, EventArgs e){person[] ps = new person[5];string result="";ps[0] = new person("張偉", Gender.男, 20);ps[1] = new person("李靜", Gender.女, 21);ps[2] = new person("黃薇", Gender.女, 19);ps[3] = new person("趙恒", Gender.男, 22);ps[4] = new person("錢沿", Gender.男, 20);label3.Text = Convert.ToString(person.Numbermales());label4.Text = Convert.ToString(person.Numberfemales());foreach (person p in ps){result =result+" "+ p.name;}label5.Text=result;}} }

姓名 請輸入老師的編號、姓名、職稱和部門
using System; using System.Collections.Generic; using System.Linq; using System.Text;namespace _1 {public class person{public int cno;public string name;public person() { }public void getxy() {cno=Convert.ToInt32(Console.ReadLine());name = Console.ReadLine();}public void display(){Console.WriteLine("編號:{0},姓名:{1}",cno,name);}}public class student: person{public string banji;public int grade;public student(){ } public void getxy(){Console.WriteLine("請輸入學生的編號、姓名、班級和成績:");cno = Convert.ToInt32(Console.ReadLine());name = Console.ReadLine();banji = Console.ReadLine();grade = Convert.ToInt32(Console.ReadLine());}public void display(){Console.WriteLine("編號:{0},姓名:{1},班級:{2},成績:{3}", cno, name,banji,grade);}}public class teacher : person{public string zhicheng;public string bumen;public teacher() { }public void getxy(){Console.WriteLine("請輸入老師的編號、姓名、職稱和部門:");cno = Convert.ToInt32(Console.ReadLine());name = Console.ReadLine();zhicheng = Console.ReadLine();bumen = Console.ReadLine();}public void display(){Console.WriteLine("編號:{0},姓名:{1},職稱:{2},部門:{3}", cno, name, zhicheng, bumen);}}class Program{static void Main(string[] args){student s1 = new student();teacher t1 = new teacher();s1.getxy();t1.getxy();s1.display();t1.display();}} }

總結

以上是生活随笔為你收集整理的C#源代码—姓名 请输入老师的编号、姓名、职称和部门的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。