C#+web=? 微软Blazor

栏目: IT技术 · 发布时间: 6年前

C#开发可以用 Blazor 在今后写前端渲染的网页了!

- C #(C sharp)是什么?

C#是微软公司发布的一种面向对象的、运行于.NET Framework和.NET C ore(完全开源,跨平台)之上的高级程序设计语言。

- 为什么会出现Blazor?

我觉得起因是因为浏览器支持WebAssembly,WebAssembly是一种新的编码方式,可以在现代的网络浏览器中运行二进制格式文件,以接近原生的性能运行。Blazor 尝试使用WebAssembly和DotNetAnywhere将.NET带回到浏览器。

C#+web=? 微软Blazor

除了用C#来开发之外,还可以让C#运行在浏览器(使用WebAssembly)上,这样dotnet的众多api我们都可以在浏览器使用了。

C#+web=? 微软Blazor

Blazor文档齐全,

https://docs.microsoft.com/zh-cn/aspnet/core/blazor/get-started?view=aspnetcore-3.1&tabs=visual-studiohttps://docs.microsoft.com/zh-cn/aspnet/core/blazor/get-started?view=aspnetcore-3.1&tabs=visual-studio

按照官网指示,先安装 .NET Core 3.1 SDK。我使用的是mac环境,直接下载dotnet的pkg安装包安装。安装之后在终端输入,安装Blazor的模板:

dotnet new -i Microsoft.AspNetCore.Components.WebAssembly.Templates::3.2.0-preview2.20160.5

我使用的是 Visual Studio Code,安装C#插件

C#+web=? 微软Blazor

终端cd到合适的文件目录,输入:

dotnet new blazorwasm -o WebApplicationMix

用Visual Studio Code打开。终端输入:

dotnet run

浏览器打开 https://localhost:5001/ ,初次体验Blazor

C#+web=? 微软Blazor

我比较看重还是Blazor可以调用dotnet提供的一个机器学习库。BlazorML5, 为Blazor提供了ML.NET的功能。

- ML.NET

开源和跨平台的机器学习框架,它可以实现

C#+web=? 微软Blazor

情绪分析、产品推荐、价格预测、物体检测、图像分类等等。微软的api梳理得更为接近应用场景。代码风格也比较简洁:

//Step 1. Create a ML Context

var ctx = new MLContext();


//Step 2. Read in the input data for model training

IDataView dataReader = ctx.Data

.LoadFromTextFile<MyInput>(dataPath, hasHeader: true);


//Step 3. Build your estimator

IEstimator<ITransformer> est = ctx.Transforms.Text

.FeaturizeText("Features", nameof(SentimentIssue.Text))

.Append(ctx.BinaryClassification.Trainers

.LbfgsLogisticRegression("Label", "Features"));


//Step 4. Train your Model

ITransformer trainedModel = est.Fit(dataReader);


//Step 5. Make predictions using your model

var predictionEngine = ctx.Model

.CreatePredictionEngine<MyInput, MyOutput>(trainedModel);


var sampleStatement = new MyInput { Text = "This is a horrible movie" };


var prediction = predictionEngine.Predict(sampleStatement);


推荐关注Blazor~

欢迎在 MIXLAB的前端社群 里进行交流,

赞赏后可得群二维码


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。

Game Engine Architecture, Second Edition

Game Engine Architecture, Second Edition

Jason Gregory / A K Peters/CRC Press / 2014-8-15 / USD 69.95

A 2010 CHOICE outstanding academic title, this updated book covers the theory and practice of game engine software development. It explains practical concepts and techniques used by real game studios,......一起来看看 《Game Engine Architecture, Second Edition》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

html转js在线工具
html转js在线工具

html转js在线工具