read chars from file to array vb.net -
the file need read in square 8x8 or nxn. chars separated spaces , @ end of line believe crlf. when try read in file crlf's when use code:
dim stream new filestream(filename, filemode.open) dim reader new streamreader(stream)
dim temparray() string = reader.readtoend.split(" ")
i stuff temparray(7) "k b"
what need after put 2d array of 8x8 or nxn sample file 8x8
or if there way 2d array out using 1d array first great.
sample file:
a b r e l r k
b r e d a o l
c r r o t d i
h p n l k m l
e p g p p l e
e e o m n o k f
s l s r g s a
e f s e h a
string.split can take array of chars want split on, can handle space, , new lines in 1 go.
try:
dim temparray() string = reader.readtoend.split(new char() {" "c, vbcr, vbcrlf})
in fact, appears if pass null/nothing separater, split default whitespace characters. should work well:
dim temparray() string = reader.readtoend.split(nothing)
Comments
Post a Comment