Created
June 8, 2017 05:36
-
-
Save ciniml/fecdc14ebb6b1dbc1fc9c4caf299ef2e to your computer and use it in GitHub Desktop.
InitializeStructArrayWithLinq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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