Skip to content

Instantly share code, notes, and snippets.

@ciniml
Created June 8, 2017 05:36
Show Gist options
  • Save ciniml/fecdc14ebb6b1dbc1fc9c4caf299ef2e to your computer and use it in GitHub Desktop.
Save ciniml/fecdc14ebb6b1dbc1fc9c4caf299ef2e to your computer and use it in GitHub Desktop.
InitializeStructArrayWithLinq
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
enum MemAttr
{
memNOUSE,
}
struct MainMemory
{
public int MachineCode { get; set; }
public MemAttr Attribute { get; set; }
public int BeginMark { get; set; }
public int EndMark { get; set; }
public int SourcePosition { get; set; }
}
class Program
{
static void Main(string[] args)
{
const int MAINMEMORYMAXADDRESS = 1024;
var mainMemoryInitialValue = new MainMemory() { SourcePosition = 0, MachineCode = 0, Attribute = MemAttr.memNOUSE, BeginMark = 0, EndMark = 0 };
var MainMemoryArray = Enumerable.Range(0, MAINMEMORYMAXADDRESS)
.Select(_ => mainMemoryInitialValue)
.ToArray();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment