Ответ:
(Для версий C# 7.2 и выше)
using System;
namespace ConsoleApp1
{
class Program
static void Main(string[] args)
Span<int> storage = stackalloc int[10];
Random r = new Random();
foreach (ref int item in storage)
item = r.Next(101)-50;
foreach (ref readonly var item in storage)
Console.Write($"{item} ");
}
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
(Для версий C# 7.2 и выше)
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Span<int> storage = stackalloc int[10];
Random r = new Random();
foreach (ref int item in storage)
item = r.Next(101)-50;
foreach (ref readonly var item in storage)
Console.Write($"{item} ");
}
}
}