public static int Sum(int[] array, int length)
{
int sum = 0;
if (array is not null && length <= array.Length)
{
for (int i = 0; i < length; i++)
{
sum += array[i]; // bounds check removed
}
}
else
{
for (int i = 0; i < length; i++)
{
sum += array[i]; // bounds check not removed
}
}
return sum;
}
JNPF
JNPF已经是一套成熟的快速开发框架,并在不断升级更新;JNPF快速开发能提高企业的竞争能力,包括降低开发成本、提高产品质量、改善客户满意程度、控制开发进度等。http://www.jnpfsoft.com/?from=优快云m
大屏设计介绍:
画布采用网格系统,自动吸附每个控件的布局,做到整齐划一;
大量可视化控件效果,零编码拖拽式操作,支持自定义样式,自定义数据库;
拖拽式自由布局,多种图表、控件、表格等组件任你摆放,想怎么放就怎么放;
数十种可视化图表示例,满足各类的阅读偏好,为您展示全面的数据可视化报告;
打破信息孤岛问题,实时为你展示数据的变化,让你随时查看公司的业务情况;
内置大量专业、酷炫的可视化动效组件、满足您对各种数据场景的动态需求。
<h1>Hashing</h1>
<p>Time: @_time</p>
<button class="btn btn-primary" @onclick="Hash">Click me</button>
@code {
private const string Sonnet18 =
@"Shall I compare thee to a summer’s day?
Thou art more lovely and more temperate:
Rough winds do shake the darling buds of May,
And summer’s lease hath all too short a date;
Sometime too hot the eye of heaven shines,
And often is his gold complexion dimm'd;
And every fair from fair sometime declines,
By chance or nature’s changing course untrimm'd;
But thy eternal summer shall not fade,
Nor lose possession of that fair thou ow’st;
Nor shall death brag thou wander’st in his shade,
When in eternal lines to time thou grow’st:
So long as men can breathe or eyes can see,
So long lives this, and this gives life to thee.";
private TimeSpan _time;
private void Hash()
{
byte[] bytes = Encoding.UTF8.GetBytes(Sonnet18);
var sw = Stopwatch.StartNew();
for (int i = 0; i < 2000; i++)
{
_ = SHA256.HashData(bytes);
}
_time = sw.Elapsed;
}
}
using System.Text.Json;
namespace SerializeToFileAsync
{
public class WeatherForecast
{
public DateTimeOffset Date { get; set; }
public int TemperatureCelsius { get; set; }
public string? Summary { get; set; }
}
public class Program
{
public static async Task Main()
{
var weatherForecast = new WeatherForecast
{
Date = DateTime.Parse("2019-08-01"),
TemperatureCelsius = 25,
Summary = "Hot"
};
string fileName = "WeatherForecast.json";
using FileStream createStream = File.Create(fileName);
await JsonSerializer.SerializeAsync(createStream, weatherForecast);
await createStream.DisposeAsync();
Console.WriteLine(File.ReadAllText(fileName));
}
}
}
// output:
//{"Date":"2019-08-01T00:00:00-07:00","TemperatureCelsius":25,"Summary":"Hot"}