必赢网上注册-亚洲必赢官方登录

MVC公司级实战,汉字转形成拼音

日期:2019-10-04编辑作者:必赢网上注册

必赢网上注册 1必赢网上注册 2必赢网上注册 3必赢网上注册 4必赢网上注册 5

上学前盘算:

4.1.1 View和Action之间数据传递的秘技
  • 弱类型ViewData[""]
  • 动态型ViewBag //dynamic
  • 动态类型Model
  • 不经常存款和储蓄TempData[""]
  • 后台:return View; //存入ViewData.Model
  • 前台:Model //其实就是WebViewPage.Medel示例:首先添加三个model类:
 public class User { public string Name { get; set; } }

在controller为变量赋值:

 public class HomeController : Controller { public ActionResult Index() { ViewData["One"] = "This is ViewData Test"; ViewBag.Two = "This is ViewBag Test"; var _user = new User { Name = "This is Model Test"}; TempData["Four"] = "This is TempData Test"; return View; //等于ViewData.Model = _user; } }

其次在View里面应用在controller的变量:

@Model FirstTest.Models.User<br/>@{ ViewBag.Title = "Index";}@ViewData["One"]<br/>@ViewBag.Two<br/>@Model.Name<br/>@TempData["Four"]<h2>Index</h2>

必赢网上注册 6

从地方的结果来看的话,对多音字的识别依然有一部分主题材料的。

3.1.1 System.IO类介绍

必赢网上注册 7必赢网上注册 8必赢网上注册 9

由此timer去设置有个别行为的接触:

  1. .net core sdk 2.0安装
  2. vs code 安装

    必赢网上注册 10公众号.png

4.1.2 TempData、ViewData和ViewBag的区别
  • ViewData是字标准的(Dictionary);
  • 必赢网上注册 ,MVC公司级实战,汉字转形成拼音。ViewBag不再是字典的键值对协会,而是dynamic型,会在程序运转的时候动态分析;
  • ViewData为object型,而ViewBag为dynamic型。dynamic型与object型的分别在动用时它会活动依据数据类型调换。

示例:

@*1. 使用字符串描述输出*@@{ string strHtml = "Hi Girl~"; @strHtml; <br />}@*2.使用HTMLHelper输出*@@{ @Html.Raw("use HTMLHelper to output"); <br />}@*3.使用HtmlString类输出*@@{ HtmlString htm = new HtmlString("use HtmlString"); @htm; <br />}@*4.使用MvcHtmlString输出*@@{ var str = MvcHtmlString.Create("use mvchtmlstring"); @str; <br/>}

必赢网上注册 11

Controller 首要担任相应顾客的输入,首要关怀的是使用程序流、输入数据的拍卖以及对相关视图输出数据的提供。

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Text.RegularExpressions;using System.Threading.Tasks;namespace HanZiZhuanHuan{ class ChinaToPinyin { #region 数组 //定义拼音区编码数组 private static int[] getValue = new int[] { -20319,-20317,-20304,-20295,-20292,-20283,-20265,-20257,-20242,-20230,-20051,-20036, -20032,-20026,-20002,-19990,-19986,-19982,-19976,-19805,-19784,-19775,-19774,-19763, -19756,-19751,-19746,-19741,-19739,-19728,-19725,-19715,-19540,-19531,-19525,-19515, -19500,-19484,-19479,-19467,-19289,-19288,-19281,-19275,-19270,-19263,-19261,-19249, -19243,-19242,-19238,-19235,-19227,-19224,-19218,-19212,-19038,-19023,-19018,-19006, -19003,-18996,-18977,-18961,-18952,-18783,-18774,-18773,-18763,-18756,-18741,-18735, -18731,-18722,-18710,-18697,-18696,-18526,-18518,-18501,-18490,-18478,-18463,-18448, -18447,-18446,-18239,-18237,-18231,-18220,-18211,-18201,-18184,-18183, -18181,-18012, -17997,-17988,-17970,-17964,-17961,-17950,-17947,-17931,-17928,-17922,-17759,-17752, -17733,-17730,-17721,-17703,-17701,-17697,-17692,-17683,-17676,-17496,-17487,-17482, -17468,-17454,-17433,-17427,-17417,-17202,-17185,-16983,-16970,-16942,-16915,-16733, -16708,-16706,-16689,-16664,-16657,-16647,-16474,-16470,-16465,-16459,-16452,-16448, -16433,-16429,-16427,-16423,-16419,-16412,-16407,-16403,-16401,-16393,-16220,-16216, -16212,-16205,-16202,-16187,-16180,-16171,-16169,-16158,-16155,-15959,-15958,-15944, -15933,-15920,-15915,-15903,-15889,-15878,-15707,-15701,-15681,-15667,-15661,-15659, -15652,-15640,-15631,-15625,-15454,-15448,-15436,-15435,-15419,-15416,-15408,-15394, -15385,-15377,-15375,-15369,-15363,-15362,-15183,-15180,-15165,-15158,-15153,-15150, -15149,-15144,-15143,-15141,-15140,-15139,-15128,-15121,-15119,-15117,-15110,-15109, -14941,-14937,-14933,-14930,-14929,-14928,-14926,-14922,-14921,-14914,-14908,-14902, -14894,-14889,-14882,-14873,-14871,-14857,-14678,-14674,-14670,-14668,-14663,-14654, -14645,-14630,-14594,-14429,-14407,-14399,-14384,-14379,-14368,-14355,-14353,-14345, -14170,-14159,-14151,-14149,-14145,-14140,-14137,-14135,-14125,-14123,-14122,-14112, -14109,-14099,-14097,-14094,-14092,-14090,-14087,-14083,-13917,-13914,-13910,-13907, -13906,-13905,-13896,-13894,-13878,-13870,-13859,-13847,-13831,-13658,-13611,-13601, -13406,-13404,-13400,-13398,-13395,-13391,-13387,-13383,-13367,-13359,-13356,-13343, -13340,-13329,-13326,-13318,-13147,-13138,-13120,-13107,-13096,-13095,-13091,-13076, -13068,-13063,-13060,-12888,-12875,-12871,-12860,-12858,-12852,-12849,-12838,-12831, -12829,-12812,-12802,-12607,-12597,-12594,-12585,-12556,-12359,-12346,-12320,-12300, -12120,-12099,-12089,-12074,-12067,-12058,-12039,-11867,-11861,-11847,-11831,-11798, -11781,-11604,-11589,-11536,-11358,-11340,-11339,-11324,-11303,-11097,-11077,-11067, -11055,-11052,-11045,-11041,-11038,-11024,-11020,-11019,-11018,-11014,-10838,-10832, -10815,-10800,-10790,-10780,-10764,-10587,-10544,-10533,-10519,-10331,-10329,-10328, -10322,-10315,-10309,-10307,-10296,-10281,-10274,-10270,-10262,-10260,-10256,-10254 }; //定义拼音数组 private static string[] getName = new string[] { "A","Ai","An","Ang","Ao","Ba","Bai","Ban","Bang","Bao","Bei","Ben", "Beng","Bi","Bian","Biao","Bie","Bin","Bing","Bo","Bu","Ba","Cai","Can", "Cang","Cao","Ce","Ceng","Cha","Chai","Chan","Chang","Chao","Che","Chen","Cheng", "Chi","Chong","Chou","Chu","Chuai","Chuan","Chuang","Chui","Chun","Chuo","Ci","Cong", "Cou","Cu","Cuan","Cui","Cun","Cuo","Da","Dai","Dan","Dang","Dao","De", "Deng","Di","Dian","Diao","Die","Ding","Diu","Dong","Dou","Du","Duan","Dui", "Dun","Duo","E","En","Er","Fa","Fan","Fang","Fei","Fen","Feng","Fo", "Fou","Fu","Ga","Gai","Gan","Gang","Gao","Ge","Gei","Gen","Geng","Gong", "Gou","Gu","Gua","Guai","Guan","Guang","Gui","Gun","Guo","Ha","Hai","Han", "Hang","Hao","He","Hei","Hen","Heng","Hong","Hou","Hu","Hua","Huai","Huan", "Huang","Hui","Hun","Huo","Ji","Jia","Jian","Jiang","Jiao","Jie","Jin","Jing", "Jiong","Jiu","Ju","Juan","Jue","Jun","Ka","Kai","Kan","Kang","Kao","Ke", "Ken","Keng","Kong","Kou","Ku","Kua","Kuai","Kuan","Kuang","Kui","Kun","Kuo", "La","Lai","Lan","Lang","Lao","Le","Lei","Leng","Li","Lia","Lian","Liang", "Liao","Lie","Lin","Ling","Liu","Long","Lou","Lu","Lv","Luan","Lue","Lun", "Luo","Ma","Mai","Man","Mang","Mao","Me","Mei","Men","Meng","Mi","Mian", "Miao","Mie","Min","Ming","Miu","Mo","Mou","Mu","Na","Nai","Nan","Nang", "Nao","Ne","Nei","Nen","Neng","Ni","Nian","Niang","Niao","Nie","Nin","Ning", "Niu","Nong","Nu","Nv","Nuan","Nue","Nuo","O","Ou","Pa","Pai","Pan", "Pang","Pao","Pei","Pen","Peng","Pi","Pian","Piao","Pie","Pin","Ping","Po", "Pu","Qi","Qia","Qian","Qiang","Qiao","Qie","Qin","Qing","Qiong","Qiu","Qu", "Quan","Que","Qun","Ran","Rang","Rao","Re","Ren","Reng","Ri","Rong","Rou", "Ru","Ruan","Rui","Run","Ruo","Sa","Sai","San","Sang","Sao","Se","Sen", "Seng","Sha","Shai","Shan","Shang","Shao","She","Shen","Sheng","Shi","Shou","Shu", "Shua","Shuai","Shuan","Shuang","Shui","Shun","Shuo","Si","Song","Sou","Su","Suan", "Sui","Sun","Suo","Ta","Tai","Tan","Tang","Tao","Te","Teng","Ti","Tian", "Tiao","Tie","Ting","Tong","Tou","Tu","Tuan","Tui","Tun","Tuo","Wa","Wai", "Wan","Wang","Wei","Wen","Weng","Wo","Wu","Xi","Xia","Xian","Xiang","Xiao", "Xie","Xin","Xing","Xiong","Xiu","Xu","Xuan","Xue","Xun","Ya","Yan","Yang", "Yao","Ye","Yi","Yin","Ying","Yo","Yong","You","Yu","Yuan","Yue","Yun", "Za", "Zai","Zan","Zang","Zao","Ze","Zei","Zen","Zeng","Zha","Zhai","Zhan", "Zhang","Zhao","Zhe","Zhen","Zheng","Zhi","Zhong","Zhou","Zhu","Zhua","Zhuai","Zhuan", "Zhuang","Zhui","Zhun","Zhuo","Zi","Zong","Zou","Zu","Zuan","Zui","Zun","Zuo" }; #endregion /// <summary> /// 汉字转换成全拼的拼音 /// </summary> /// <param name="Chstr">汉字字符串</param> /// <returns>转换后的拼音字符串</returns> public static string ToPinyin(string Chstr) { Regex reg = new Regex("^[u4e00-u9fa5]$");//验证是否输入汉字 byte[] arr = new byte[2]; string pystr = ""; int asc = 0, M1 = 0, M2 = 0; char[] mChar = Chstr.ToCharArray();//获取汉字对应的字符数组 for (int j = 0; j < mChar.Length; j++) { //如果输入的是汉字 if (reg.IsMatch(mChar[j].ToString { arr = System.Text.Encoding.Default.GetBytes(mChar[j].ToString; M1 = ; M2 = ; asc = M1 * 256 + M2 - 65536; if (asc > 0 && asc < 160) { pystr += mChar[j]; } else { switch  { case -9254: pystr += "Zhen"; break; case -8985: pystr += "Qian"; break; case -5463: pystr += "Jia"; break; case -8274: pystr += "Ge"; break; case -5448: pystr += "Ga"; break; case -5447: pystr += "La"; break; case -4649: pystr += "Chen"; break; case -5436: pystr += "Mao"; break; case -5213: pystr += "Mao"; break; case -3597: pystr += "Die"; break; case -5659: pystr += "Tian"; break; default: for (int i = (getValue.Length - 1); i >= 0; i--) { if (getValue[i] <= asc)//判断汉字的拼音区编码是否在指定范围内 { pystr += getName[i];//如果不超出范围则获取对应的拼音 break; } } break; } } } else//如果不是汉字 { pystr += mChar[j].ToString();//如果不是汉字则返回 } } return pystr;//返回获取到的汉字拼音 } }}
3.3.1 二进制文件读取器(BinaryReader)/编写器(BinaryWriter)介绍

必赢网上注册 12

示例:

using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Text;using System.Threading.Tasks;namespace BinaryTest{ class Program { static void Main(string[] args) { int i = 0; char[] invalidPathChars = Path.InvalidPathChars; MemoryStream memStream = new MemoryStream(); BinaryWriter binWriter = new BinaryWriter(memStream); //写入内存 binWriter.Write("Invalid file path characers are:"); for (i = 0; i < invalidPathChars.Length; i++) { binWriter.Write(invalidPathChars[i]); } //用作生成编写器的内存流同样作为生成读取器的内存流 BinaryReader binReader = new BinaryReader(memStream); //设置流的起点 memStream.Position = 0; //从内存中读取数据,并把数据写入控制台 Console.Write(binReader.ReadString; char[] memoryData = new char[memStream.Length - memStream.Position]; for (i = 0; i < memoryData.Length; i++) { memoryData[i] = Convert.ToChar(binReader.Read; } Console.WriteLine(memoryData); } }}

必赢网上注册 13

出人意料想起来大学一年级学c语言用当中的c%画的心形,哈哈,趁此再来一波(在上边的代码里加以改造):

必赢网上注册 14

using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Text;using System.Threading;using System.Threading.Tasks;namespace BinaryTest{ class Program { static void Main(string[] args) { int i = 0; char[] invalidPathChars = Path.InvalidPathChars; MemoryStream memStream = new MemoryStream(); BinaryWriter binWriter = new BinaryWriter(memStream); //写入内存 binWriter.Write("Invalid file path characers are:"); for (i = 0; i < invalidPathChars.Length; i++) { binWriter.Write(invalidPathChars[i]); } //用作生成编写器的内存流同样作为生成读取器的内存流 BinaryReader binReader = new BinaryReader(memStream); //设置流的起点 memStream.Position = 0; //从内存中读取数据,并把数据写入控制台 //Console.Write(binReader.ReadString; char[] memoryData = new char[memStream.Length - memStream.Position]; for (i = 0; i < memoryData.Length; i++) { memoryData[i] = Convert.ToChar(binReader.Read; } //Console.WriteLine(memoryData); while { List<int> x = new List<int> { 5,6,7,8,9,10,11,12}; int index = new Random().Next; PrintLove(memoryData, x[index]); Thread.Sleep; Console.Clear(); } } private static void PrintLove(char[] memoryData,int i) { for (float y = 1.3f; y >= -1.1f; y -= 0.06f) { for (float x = -1.2f; x <= 1.2; x += 0.025f) { if (Math.Pow((x * x + y * y - 1.0), 3) - x * x * y * y * y <= 0.0) Console.Write; else Console.Write(memoryData[i]); } Console.WriteLine(); } } }}

必赢网上注册 15

4.3.1 Action 方法参数与再次来到值

1.通过Request.Form["name"]梯次获取表单提交的数目首先在Models下增加ASO.NET实体数据模型,这里运用DB First添加Action方法UpdateCustomerInfo

 public ActionResult UpdateCustomerInfo() { return View(); } [HttpPost] public string UpdateCustomerInfo(FormCollection form) { return Request.Form["ContactName"]; }

添加UpdateCustomerInfo视图

@model FristTest.Models.Customers@{ ViewBag.Title = "UpdateCustomerInfo";}@using (Html.BeginForm{ @Html.TextBoxFor(x => x.ContactName) <input type="submit" value="修改" />}

微信公众号:

必赢网上注册 16公众号.png

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Text.RegularExpressions;namespace HanZiZhuanHuan{ class Program { static void Main(string[] args) { var x = ChinaToPinyin.ToPinyin("我是一个好孩子~"); Console.WriteLine(x.ToUpper; Console.ReadLine(); } }}
3.1.2 File类的常用方法

File类提供用于创设、复制、删除、移动和开采文件的静态方法,并协理创制FileStream对象。

必赢网上注册 17

小练习:

using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Text;using System.Threading.Tasks;namespace FileTest{ class Program { static void Main(string[] args) { string path = @"D:\Test.txt"; if (!File.Exists { //创建文件,以便写入内容 using (StreamWriter sw = File.CreateText { List<string> ls_string = new List<string> {"a","b","c","d","e","f","g","h","i","j","k","l" }; foreach (var tes in ls_string) { sw.Write; } foreach (var tes in ls_string) { sw.WriteAsync; } } } //打开文件,从中读取数据 using (StreamReader sr = File.OpenText { string s = ""; while ((s = sr.ReadLine != null) { Console.WriteLine; } } try { //删除复制 string path2 = "PathTwo.txt"; File.Delete; File.Copy(path, path2); File.Delete; } catch (Exception ex) { Console.WriteLine("{0}", ex.ToString; } Console.ReadLine(); } }}
 private void button1_Click(object sender, EventArgs e) { for (int i = 1; i <= 100; i++) { this.progressBar1.Value = i; } }

必赢网上注册 18

3.4.1 读写内部存款和储蓄器流——MemoryStream类

必赢网上注册 19

有关内部存款和储蓄器流对象中主要的特性:Length属性代表了内部存款和储蓄器流对象存放的多少的真是长度,而Capacity属性则代表了分红给内部存款和储蓄器流的内部存款和储蓄器空间大小。

本文由必赢网上注册发布于必赢网上注册,转载请注明出处:MVC公司级实战,汉字转形成拼音

关键词:

DevExpress中GridControl的行使笔记,0即以后了

在 .Net官方博客中也是有增高 .NET Core for Desktop的有的优势: out 变量( int.TryParse("123", out var num); ) 优化元祖帮衬,帮...

详细>>

MVC公司级实战,Api网关教程

在上一篇[.net core项目实战之基于RestfulAPI+Swagger项目搭建]尊敬介绍了体系WebApi的宗旨搭建,本篇首要针对开垦进度中一...

详细>>

阐释和条件搭建,质量测量检验

近些日子在改换/整理Aquarius.Weixin项目,后天修改了一晃事先写的增多DI的恢宏方法,遇到了不明了怎么手动深入分析...

详细>>

【bwin必赢亚洲手机版】重定向之后还有可能会访

熔断计谋(Circuit-breaker) bwin必赢亚洲手机版 ,假诺调用有些目的服务出现过多超时、万分等状态,能够运用一按期...

详细>>