C# Complete Tutorials – 34 – Multidimensional Arrays [w/ subs]



00:00:00 – in this video we're going to learn about
00:00:03 – double arrays so first of all why do we
00:00:05 – have them please do open up a project
00:00:08 – and delete all the code place your
00:00:09 – cursor with mine is flickering see that
00:00:11 – way there now looks very careful if I
00:00:15 – hit the space bar see how it moves
00:00:18 – horizontally now look very carefully at
00:00:20 – the what's happening down below as I do
00:00:22 – that if he does that column number there
00:00:25 – is changing right so notice that the
00:00:27 – lane and laying the line has been fixed
00:00:29 – at one and the things there is changing
00:00:31 – see that ok let's light it back that
00:00:34 – means when you move horizontally across
00:00:37 – that's saying that the role has been
00:00:38 – fixed but the columns are going and
00:00:43 – we're going over the column you see that
00:00:45 – and they're changing in value ok next
00:00:47 – imagine the following imagine we fix a
00:00:51 – column but move down across the road so
00:00:53 – that that corresponds to this now so
00:00:56 – that is a row row row row row and you
00:01:00 – can see that down below as I go down
00:01:01 – here if you dance the role changes about
00:01:04 – the column the entire time saves us
00:01:05 – fixed at one so here's a very you know
00:01:07 – direct and clear application of the
00:01:09 – logics of double erase ok keeping track
00:01:13 – of the position of the cursor and pull
00:01:15 – it up ok come next what they're going to
00:01:19 – do as a following type using system and
00:01:23 – then type class programs you are
00:01:24 – simplifying the code no namespace this
00:01:27 – will be sufficient for our purposes this
00:01:29 – time and now you're going to type static
00:01:30 – void main static void main an open close
00:01:36 – parentheses and then open close curly
00:01:38 – braces and notice that this time don't
00:01:41 – put anything inside main between the
00:01:42 – parenthesis this is sufficient for our
00:01:43 – purposes ok now we make it two
00:01:47 – dimensional array you are going to type
00:01:49 – the following you will type string like
00:01:54 – that then put a comma there now you're
00:01:57 – going to say they are our equals new
00:02:00 – string to specify the dimensions of
00:02:03 – their race they taught some type
00:02:04 – something like we buy five close out the
00:02:06 – semicolon and so what this tells us is
00:02:11 – that make an array
00:02:13 – and the reserve memory for it get it
00:02:16 – kind of right side with the cementery
00:02:20 – reservation and further because it's 3
00:02:23 – by 5 that means it can store 15 entries
00:02:28 – like this three times five is fifteen or
00:02:30 – five times three yes so the first one to
00:02:36 – three is the number of rows and the five
00:02:40 – of the number of columns okay in other
00:02:45 – words that first three that's the first
00:02:47 – dimension and a five of the second
00:02:48 – dimension arose first column second all
00:02:51 – right that's the summary information
00:02:53 – here in that declaration of assignment
00:02:55 – and member reservation rather relaxed
00:02:59 – let me delete the code that I have down
00:03:01 – below for reference all right again for
00:03:12 – the considerable intellectual
00:03:14 – expenditure of energy okay so next we're
00:03:16 – going to do this for and now we're going
00:03:20 – to type integer a row number like this
00:03:22 – okay equals 0 so this here says look at
00:03:26 – the first row that's what it says ok
00:03:28 – they're going to say while the row
00:03:30 – number is less than the matrix that get
00:03:32 – length ok notice rename it to matrix
00:03:38 – just edible all right anymore there is a
00:03:41 – limit in matrix dot and then get length
00:03:44 – now put a zero and there that is the
00:03:47 – number of rows get Landon 0 is the
00:03:50 – number of rows ok they're young now
00:03:54 – remember indices though is begin at 0
00:03:56 – and go up to n minus 1 in that case
00:04:00 – that's why it says less than matrix does
00:04:02 – your length 0 all right now I going to
00:04:04 – say here I am general number plus plus
00:04:07 – I'm very accustomed to eyes and JS
00:04:09 – alright so now open close curly braces
00:04:13 – so line below is used for going overalls
00:04:20 – like that they go so see in a moment of
00:04:25 – the means more clearly next one
00:04:26 – here line below is used for going over
00:04:32 – columns within a row okay so that means
00:04:37 – you would type again type 4 and then hit
00:04:39 – tab tab we need another inner loop okay
00:04:42 – then changed it to call num notice
00:04:45 – everything else within it is also change
00:04:48 – to calm them right Seattle feel like
00:04:50 – this is very flexible I change this here
00:04:52 – too late rigs get lines and now put a
00:04:55 – one in there and that's it okay so this
00:04:59 – will get the number of columns and again
00:05:01 – that would be the second dimension in
00:05:04 – this case so once we have this we want
00:05:06 – to store some values to be printed to
00:05:08 – this between inside there ray how are
00:05:10 – you going to store these values well let
00:05:14 – me move this up a little that will look
00:05:17 – like this hero type matrix and then that
00:05:20 – and then row number comma call number
00:05:26 – like that we are so this here will score
00:05:29 – values inside the matrix that's
00:05:32 – essentially assigned values you will
00:05:33 – type the following code where we are
00:05:36 – going to store in the address of
00:05:37 – excelled flow inside the array inside
00:05:41 – array score address of each cell like
00:05:48 – that ok so now type here equals then
00:05:51 – you're going to put a couple of these
00:05:53 – and close them within double quotes
00:05:54 – separate them out again like that now
00:06:00 – here's going to put this cell addresses
00:06:02 – you type now plus Rho numb and then plus
00:06:06 – double quote comma space close the
00:06:10 – double quote plus and then column number
00:06:13 – and then I wanted more pucks like that
00:06:15 – getting close this with a semicolon so
00:06:19 – it works all right next once you print a
00:06:24 – row then you've got to skip down to the
00:06:26 – next role to accomplish that you can go
00:06:29 – with console dot write line there you go
00:06:35 – closes with a semicolon so skip down to
00:06:38 – mix row and then go over to columns
00:06:40 – within
00:06:40 – ro all right now let me delete this code
00:06:44 – that i have done below there's one more
00:06:48 – thing that we have to do and that is to
00:06:53 – actually because this here this line
00:06:55 – this will sell this we have to print it
00:06:57 – also so the printer gonna say no harmful
00:07:01 – that right line and now you'll say
00:07:02 – printable matrix like that and then put
00:07:06 – the row number and karma call number
00:07:08 – close up with a semicolon and to make
00:07:11 – everything spaced out put a space in
00:07:14 – there like that okay there yeah that
00:07:17 – would actually print with the purpose of
00:07:18 – the line just put there and so print
00:07:23 – entries from array I'm screening like
00:07:27 – that mr. purpose okay skip down to the
00:07:31 – next row there you go so this is the
00:07:32 – heart of the program right here yeah
00:07:36 – heavily annotated for maximum clarity
00:07:38 – help now to make use of this you
00:07:40 – absolutely have to use the step into the
00:07:44 – first of all give it up build make sure
00:07:45 – it takes is gonna with diva again
00:07:54 – stepped into a few 11 all right let me
00:07:59 – modify this window here first of all
00:08:00 – criticizes give it a freaking slow all
00:08:05 – right let me get to the window right
00:08:07 – here as you modify the size of the font
00:08:11 – it would definitely change it to that
00:08:17 – one for the kobold make it 24 there we
00:08:20 – are that big I'll play I'll place this
00:08:24 – on the side that it pin it over so
00:08:30 – control function of faded with window on
00:08:32 – top all right not that bit of a catch
00:08:36 – I'm trying it again after launch window
00:08:39 – on top of one second
00:08:44 – I go go at eight ok now look very
00:08:55 – carefully as we go through the process
00:08:56 – let's go step them make that all right
00:08:59 – expand matrix right here and you see
00:09:01 – that so this thing has the memory is
00:09:03 – work for it correct but notice that each
00:09:05 – of those value there is a mole ok there
00:09:10 – you go because each one is a strength of
00:09:11 – the people value for strength no all
00:09:14 – right next one there you go no now look
00:09:17 – very carefully at a screen it will
00:09:18 – happen right now we are about to start
00:09:21 – going over the CI point 1000 now I check
00:09:25 – the column number implemented by one
00:09:27 – check the condition and then we print
00:09:29 – the print of that okay now this is not
00:09:33 – the way you wanted to print through this
00:09:35 – closes for a second and change that to
00:09:39 – write like that again that is what we
00:09:42 – want this is the one that will stack it
00:09:44 – horizontally rather than vertically you
00:09:46 – know so debugging step into young let me
00:09:54 – get the window back here we are
00:10:01 – alright so it's very carefully now as
00:10:05 – before set the row index and now go over
00:10:09 – the columns within the row that's what
00:10:11 – this is doing for us take a look to see
00:10:13 – this because we are stacking out the
00:10:15 – columns and only the second number is
00:10:18 – changing but the first one is 00 01 02
00:10:20 – physiologic that's it right now the
00:10:25 – condition will fail once you get to the
00:10:30 – end you see the condition fails cog for
00:10:32 – that right line pushes up that push
00:10:34 – yourselves down to the next row where we
00:10:37 – ensure that we are not past the number
00:10:39 – of rows and then we go over the columns
00:10:42 – within that role you see that look very
00:10:45 – carefully you see that we're checking it
00:10:46 – out horizontally there you go for some
00:10:51 – mechanical process thankfully you can
00:10:54 – understand that same thing next stage so
00:10:57 – fix the next row and go over the columns
00:10:59 – within that row that's what the inner
00:11:01 – loop does it goes over two columns
00:11:02 – printing the entries there you go see
00:11:05 – that one at a time very mechanically
00:11:08 – right so they're not the last step the
00:11:14 – condition fails we egg with the program
00:11:16 – and that's it so please type the code
00:11:20 – and go through it with the debugger and
00:11:21 – as an assignment I want you to have the
00:11:24 – ability to able to be able to read two
00:11:27 – entries from the user and specify the
00:11:28 – number of rows and columns as the user
00:11:30 – sees fit and very much


Video Url:
http://youtu.be/MkPDxV2CcZM

Comments

comments