当前位置: 首页 > news >正文

辽阳银梦网站建设网络需求分析

辽阳银梦网站建设,网络需求分析,开发网站需要哪些技术,企业品牌推广的核心目的是目录 .NET实操#xff1a;创建项目执行 C#基础语法数据类型变量实操001_变量如何在一个解决方案 中创建另一个项目实操002结构实操003-if else实操004-多分支多行注释按钮实操#xff1a;循环 面向对象基础如何在同一个项目下创建新的.cs文件实操-类的定义与访问实操-练习实操… 目录 .NET实操创建项目执行 C#基础语法数据类型变量实操001_变量如何在一个解决方案 中创建另一个项目实操002结构实操003-if else实操004-多分支多行注释按钮实操循环 面向对象基础如何在同一个项目下创建新的.cs文件实操-类的定义与访问实操-练习实操-方法实操计算器 综合实例 .NET dotnet5.NET合并了.NET Framework、.NET Core(可以跨平台)实操创建项目 我用的Visual Studio2022 先创建新项目再点击下一步后说明了解即可在找到相应文件位置后点击 “生成” 下方会出现 成功 之后 Debug 下会生成很多文件其中 xxx.exe 是生成的可执行文件在.NET平台是一种通用文件执行 C#基础语法 数据类型 简单数据类型值类型引用类型值存储在堆里面地址存储在栈里面) 变量 实操001_变量 namespace Demo001_变量 {internal class Program{ /////是注释 解释说明的作用/// summary/// 主方法程序的入口/// /summary/// param nameargs/paramstatic void Main(string[] args){//声明变量存储数据string message;//给变量赋值message 欢迎来到C#的世界;//使用变量Console.WriteLine(message);//存储员工的信息工号姓名性别入职日期基本工资部门岗位string emplyeeNo, name;bool gender;DateTime jobInDateTime;double salary;string departmentName;string job;Console.Write(请输入工号);emplyeeNo Console.ReadLine();Console.Write(请输入姓名);name Console.ReadLine();Console.Write(请输入性别);gender Convert.ToBoolean(Console.ReadLine());Console.Write(请输入入职日期yyyy-mm-dd:);jobInDateTime Convert.ToDateTime(Console.ReadLine());Console.Write(请输入基本工资);salary Convert.ToDouble(Console.ReadLine());Console.Write(请输入部门);departmentName Console.ReadLine();Console.Write(请输入岗位);job Console.ReadLine();//输出个人信息Console.WriteLine($工号{emplyeeNo}\n $姓名{name}\n $性别{gender}\n $入职日期{jobInDateTime}\n $基本工资{salary}\n $部门{departmentName}\n $岗位{job});}} }如何在一个解决方案 中创建另一个项目 后面的步骤前面有讲过。 注意点击 配置启动项 勾选 当前项目![启动项设置]](https://img-blog.csdnimg.cn/fd028c9cac10418a891dfc2ab073013b.png) 实操002 namespace Demo002_算术运算符 {internal class Program{static void Main(string[] args){DateTime dateOfBirth Convert.ToDateTime(1995-10-2);int age DateTime.Now.Year - dateOfBirth.Year;Console.WriteLine(年龄age);//age 和 age 区别//先用再加 先加再用bool gender true;gender false;//string sex gender true ? 男 : 女;string sex !gender ? 男 : 女;Console.WriteLine($性别{sex});Console.WriteLine();Console.Write(请输入账号);string loginId Console.ReadLine();Console.Write(请输入密码);string loginPassword Console.ReadLine();string loginMsg loginId admin loginPassword 123456 ? 登录成功 : 用户名或密码错误登录失败;Console.WriteLine(loginMsg);}} }结构 实操003-if else namespace Demo003_选择结构 {internal class Program{static void Main(string[] args){Console.WriteLine(请问是否进行C#学习y/n:);string input Console.ReadLine().ToLower();//输入转换为小写 .ToUpper()转化为大写if (input ! y input ! n) {Console.WriteLine(输入有误);}else{if (input y){Console.WriteLine(继续阅读);}else{Console.WriteLine(停止阅读);}}}} }实操004-多分支 namespace Demo004_多分支 {internal class Program{static void Main(string[] args){Console.WriteLine(*******年终奖判定程序**********);Console.WriteLine(请输入基本工资);double salary Convert.ToDouble(Console.ReadLine());Console.WriteLine(请输入考核等级ABCD);char level Convert.ToChar(Console.ReadLine().ToUpper());double reward;//奖金if (level A || level D)Console.WriteLine(等级输入有误);//多分支else{//if (level A)//reward salary * 6;//else if (level B)//reward salary * 3;//else if (level C)//reward salary * 2;//else//reward salary;//只能写等值判断switch (level){case A:reward salary * 6;break;case B:reward salary * 3;break;case C:reward salary * 2;break;default:reward salary;break;}Console.WriteLine($年终奖是{reward});}}} }多行注释按钮 实操循环 namespace Demo005_循环结构 {internal class Program{static void Main(string[] args){//forint i;//定义在外面比较好for(i 0; i 3; i) {Console.WriteLine(重要的事情说三遍);}//登录系统输入用户名和密码三次有效string userName, password;for(i 0;i 3; i){Console.WriteLine($第{i 1}次登录开始......);Console.Write(请输入用户名);userName Console.ReadLine();Console.Write(请输入密码);password Console.ReadLine();if(userName admin password admin) {Console.WriteLine(登录成功);break;//强制退出循环}else if (i 2) {Console.WriteLine(用户名或密码错误登录失败);}else{Console.WriteLine(三次机会已用完账号已锁定);}}}} }面向对象基础 如何在同一个项目下创建新的.cs文件 实操-类的定义与访问 Employee.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace Demo006_类的定义和访问 {/*** 类名Employee* 功能模拟所有的职员对象* */public class Employee{//internal 去掉也不会报错 internal只能在这里访问到 public是都可以访问到//成员变量字段特征//string employeeNo;//这是私有的privatepublic string employeeNo;public string name;public bool gender;public double salary;//构造方法在实例化对象时调用//构造方法名称必须与类名一致public Employee(){//默认存在但是调用了带参构造在没有定义无参构造的时候调用无参会报错建议带上无参构造//Console.WriteLine(正在实例化员工对象...);}/// summary/// 带参数构造方法/// /summary/// param nameemployeeNo员工号/param/// param namename姓名/param/// param namegender性别/param/// param namesalary工资/parampublic Employee(string employeeNo, string name, bool gender, double salary){//this关键字正在实例化的对象this.employeeNo employeeNo;this.name name;this.gender gender;this.salary salary;}//方法对象的行为能力public void ShowEmployeeMsg(){Console.WriteLine(${this.employeeNo}\t{this.name}\t{(this.gender true ? 男 : 女)}\t{this.salary});}} } Program.cs namespace Demo006_类的定义和访问 {internal class Program{static void Main(string[] args){//实例化对象Employee emp01 new Employee();//访问变量对象名.变量名emp01.employeeNo 1234;emp01.name 张三;emp01.gender true;emp01.salary 6589;Employee emp02 new Employee();emp01.employeeNo 1235;emp01.name 王小二;emp01.gender false;emp01.salary 7800;Employee emp03 new Employee(1236, rose, false, 6500);//Console.WriteLine(${emp01.employeeNo}\t{emp01.name}\t{(emp01.gender true? 男:女)}\t{emp01.salary});//Console.WriteLine(${emp02.employeeNo}\t{emp02.name}\t{(emp02.gender true ? 男 : 女)}\t{emp02.salary});//Console.WriteLine(${emp03.employeeNo}\t{emp03.name}\t{(emp03.gender true ? 男 : 女)}\t{emp03.salary});//调用方法对象名.方法名emp01.ShowEmployeeMsg();emp02.ShowEmployeeMsg();emp03.ShowEmployeeMsg();}} }实操-练习 使用OOP的思想模拟个人手机的信息包含手机品牌型号价格和颜色 开机和关机的功能Phone.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace Demo007_练习 {/*** 类名Phone* 功能模拟手机对象* */public class Phone{public string brand;//品牌public string type;//型号public double price;//价格public string color;//颜色public Phone(){Console.WriteLine(正在实例化手机对象...);}public Phone(string brand, string type, double price, string color){this.brand brand;this.type type;this.price price;this.color color;}public void OpenPhone(){Console.WriteLine(${this.brand}品牌{this.type}型号{this.price}元{this.color}的手机正在开机......);}public void ClosePhone(){Console.WriteLine(${this.brand},{this.type},{this.price},{this.color} 关机了);}}} 实操-方法 Employee.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Serialization;namespace Demo006_类的定义和访问 {/*** 类名Employee* 功能模拟所有的职员对象* */public class Employee //internal 去掉也不会报错 internal只能在这里访问到 public是都可以访问到{//成员变量字段特征//string employeeNo;//这是私有的privatepublic string employeeNo;public string name;public bool gender;public double salary;//构造方法在实例化对象时调用//构造方法名称必须与类名一致public Employee() {//默认存在但是调用了带参构造在没有定义无参构造的时候调用无参会报错建议带上无参构造Console.WriteLine(正在实例化员工对象...);}public Employee(string employeeNo, string name, bool gender, double salary){//this关键字正在实例化的对象this.employeeNo employeeNo;this.name name;this.gender gender;this.salary salary;}//方法对象的行为能力public void ShowEmployeeMsg(){Console.WriteLine(${this.employeeNo}\t{this.name}\t{(this.gender true ? 男 : 女)}\t{this.salary});}//请假public void SendMsg(string type,DateTime beginDate,int days,string reason){Console.WriteLine(${this.employeeNo}的员工申请{type});Console.WriteLine($开始日期{beginDate}\n $请假天数{days}\n $结束日期{beginDate.AddDays(days)}\n $请假事由{reason}\n);}//年终奖public double GetReward(string level){double reward;switch (level){case A:reward this.salary * 6;break;case B:reward this.salary * 3;break;case C:reward this.salary * 2;break;default:reward this.salary;break;}return reward;//返回语句}} } Program.cs using Demo006_类的定义和访问;namespace Demo008_方法 {internal class Program{static void Main(string[] args){Employee employee1 new Employee(1234,张三,true,5000);employee1.SendMsg(事假, Convert.ToDateTime(2023-11-10 09:00:00), 2, 家里有事);Employee employee2 new Employee(1235, 李四, true, 6000);employee2.SendMsg(婚假, DateTime.Now, 10, 回家结婚);Console.Write(请输入考核等级);string inputLevel Console.ReadLine();double money employee1.GetReward(inputLevel);Console.WriteLine($年终奖金是{money});}} }实操计算器 Calculator.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace Demo009_Calculator {public class Calculator{public int GetResult(int a, int b, string type){int c 0;if (type ){c a b;}else if (type -){c a - b;}else if (type *){c a * b;}else if (type /){if (b 0){Console.WriteLine(除数为0无法计算);}else{c a / b;}}return c;}}} Program.cs namespace Demo009_Calculator {internal class Program{static void Main(string[] args){//使用OOP思想实现两个数的加减乘除运算。Calculator calculator new Calculator();Console.Write(请输入第一个数);int a Convert.ToInt32(Console.ReadLine());Console.Write(请输入第二个数);int b Convert.ToInt32(Console.ReadLine());Console.Write(请输入运算符/ - / * / /);string type Console.ReadLine();//计算int c calculator.GetResult(a, b, type);Console.WriteLine(${a}{type}{b}{c});}} }综合实例 *以OOP的思想实现猜拳游戏 *计算机和用户实现猜拳可以出剪刀、石头和布。 *剪刀用0表示石头用1表示布用2表示。 *程序启动系统默认可以玩10局用户玩完一局之后可以按任意键继续按q退出退出后需显示实际玩了几局用户赢了几局电脑赢了几局平了几局如果用户赢的局数大于电脑赢的局数显示用户大获全胜如果电脑赢的局数大于用户赢的局数显示用户败给了电脑如果赢的局数相同显示打成了平手。*每一局游戏的游戏规则 *先用户出拳输入0 - 2为后显示用户出的拳是什么如果用户出的不是0 - 2提示用户输入错误重新输入直到用户输入正确为止 *再由电脑随机出拳电脑产生0 - 2之间的随机数也要显示电脑出的拳是什么然后判断电脑和用户的输赢关系并给出适当的提示比如本局是用户赢了还是电脑赢了还是平局Player.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Channels; using System.Threading.Tasks;namespace Demo010_综合案例 { /// summary/// 玩家类/// /summarypublic class Player{public string name;//玩家的昵称/// summary/// 玩家出拳/// /summary/// returns/returnspublic int Throw(){while (true){try{Console.WriteLine($请{this.name}出拳);int point Convert.ToInt32(Console.ReadLine());if (point 0 point 3){return point;}elseConsole.WriteLine(输入有误请输入0-2);}catch (Exception ex){Console.WriteLine (输入有误请输入数字);}}}} } Computer.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace Demo010_综合案例 {public class Computer{public int CreateRandomNum(){Random r new Random();return r.Next(3);}} } GuessGame.cs using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks;namespace Demo010_综合案例 {/// summary/// 猜拳游戏类/// /summarypublic class GuessGame{Player player new Player();Computer computer new Computer();/// summary/// 输入玩家的昵称/// /summarypublic void InputePlayName(){Console.Write(请输入昵称);player.name Console.ReadLine();}/// summary/// 欢迎界面/打印界面/// /summarypublic void ShowMsg() {Console.WriteLine(*****************************);Console.WriteLine(******欢迎来到猜拳游戏*******);Console.WriteLine(*****************************);}/// summary/// 程序启动/// /summarypublic void Start(){this.ShowMsg();InputePlayName();int p1 player.Throw();int p2 computer.CreateRandomNum();string quan1 ConvertInToString(p1);string quan2 ConvertInToString(p2);Console.WriteLine(${player.name}出的拳是{quan1});Console.WriteLine($电脑出的拳是{quan2});Judge(p1, p2);Console.WriteLine(是否继续下一局按任意键继续按q退出);string input Console.ReadLine().ToLower();if(input q){Console.WriteLine(游戏正在退出...);Console.ReadKey();//需要按一个键}Console.ReadKey();Console.Clear();}/// summary/// 数字的点数转换为字符串的拳/// /summary/// param namepoint点数/param/// returns拳/returnspublic string ConvertInToString(int point){if(point 0) {return 剪刀;}if (point 1){return 石头;}return 布;}/// summary/// 判断输赢/// /summary/// param nameplayerPoint玩家的点数/param/// param namecomputerPoint电脑的点数/parampublic void Judge(int playerPoint, int computerPoint){//0剪刀 1石头 2布//用户赢0(2)-2,1(0)1,2(1)1int diff playerPoint - computerPoint;if (diff 0) {Console.WriteLine(平局);}else if (diff -2 || diff 1) {Console.WriteLine($用户{player.name}赢了一局);}else{Console.WriteLine(电脑赢了一局);}}} } Program.cs namespace Demo010_综合案例 {internal class Program{static void Main(string[] args){//以OOP的思想实现猜拳游戏//计算机和用户实现猜拳可以出剪刀、石头和布。//剪刀用0表示石头用1表示布用2表示。//程序启动系统默认可以玩10局用户玩完一局之后可以按任意键继续按q退出退出后需显示实际玩了几局用户赢了几局电脑赢了几局平了几局如果用户赢的局数大于电脑赢的局数显示用户大获全胜如果电脑赢的局数大于用户赢的局数显示用户败给了电脑如果赢的局数相同显示打成了平手。//每一局游戏的游戏规则//先用户出拳输入0 - 2为后显示用户出的拳是什么如果用户出的不是0 - 2提示用户输入错误重新输入直到用户输入正确为止//再由电脑随机出拳电脑产生0 - 2之间的随机数也要显示电脑出的拳是什么然后判断电脑和用户的输赢关系并给出适当的提示比如本局是用户赢了还是电脑赢了还是平局GuessGame guessGame new GuessGame();guessGame.Start();Player p new Player(); p.name 张三;}} }
http://www.zqtcl.cn/news/394593/

相关文章:

  • 品牌网站建设 磐石网络官方网站网络科技公司 网站建设
  • 厦门启明星网站建设学校网站模板 中文
  • 高端手机网站平台深圳网上申请个人营业执照
  • 沈阳怎么做网站西亚网站建设科技
  • 做外贸免费的网站有哪些专业简历制作
  • 园林景观设计网站推荐国内wordpress主题
  • 一流的免费网站建设摄影网站源码
  • 深圳高端网站设计公司怎样开发手机网站建设
  • 做网站需要用c语言吗新闻热点
  • 做网站需要交维护费么网站建设详细合同范本
  • 网站运营需要做什么静态网站作品
  • 如何做旅游休闲网站苍南做网站
  • wordpress jp theme关键词排名优化公司成都
  • Soho外贸常用网站wordpress下不了插件吗
  • 企业网站建设小技巧有哪些WordPress网站小程序
  • 公司招聘网站续费申请seo编辑是干什么的
  • 58同城泉州网站建设人工投票平台app
  • dede 网站地图 插件网站引导页flash
  • 聊城做网站的公司渠道网站总体结构
  • 北京比较大的网站建设公司wap网站引导页特效
  • 做关于植物的网站即墨网站设计
  • 怎么提升网站收录商品网页制作
  • 做网站建设的平台wordpress5.0发布
  • 站长工具a级查网站域名
  • 免费做网站电话手机开发者模式打开有什么影响
  • 上海免费网站建站模板毕节做网站优化
  • 影响网站建设的关键点手机网站制作app
  • 商务网站建设的流程深圳模板网站建设案例
  • 做中英文网站多少钱方维制网站
  • 做一个信息发布网站要多少钱开发小程序多少钱一个