Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:05,880 --> 00:00:11,440
So we have linked an element that we defined in some old bag to the same old see C-s file.
2
00:00:11,790 --> 00:00:17,840
We were able to access these resoled label and assign a new value to ensconce and property.
3
00:00:18,480 --> 00:00:24,870
But we may not understand exactly how this happens because this is not just some magical thing that
4
00:00:24,870 --> 00:00:28,420
happens when you define an element instead of some.
5
00:00:28,470 --> 00:00:35,940
There is some code actually happening for these to be available directly from the C-sharp file.
6
00:00:36,690 --> 00:00:43,150
So what is exactly going on here has a lot to do with partial classes.
7
00:00:43,170 --> 00:00:50,430
It turns out that one C-Sharp you are able to define partial definitions of certain elements.
8
00:00:50,430 --> 00:00:52,510
For example classes are methods.
9
00:00:52,890 --> 00:01:00,790
This means that a single class or a single method could be defined even in more than one file.
10
00:01:01,170 --> 00:01:06,650
And that is exactly what is going on with our main window class.
11
00:01:06,660 --> 00:01:10,580
Notice that precisely it is marked as partial.
12
00:01:10,680 --> 00:01:16,320
It is a public class and don't worry if you don't fully understand what it was and how you say it how
13
00:01:16,320 --> 00:01:17,470
to define it.
14
00:01:17,520 --> 00:01:20,570
We are going to learn that in the coming sections.
15
00:01:20,780 --> 00:01:27,990
What I want to focus on is the fact that this is partial meaning that a single class can be defined
16
00:01:28,080 --> 00:01:30,410
in different files.
17
00:01:30,990 --> 00:01:35,790
So our main window class is being defined in more than one file.
18
00:01:36,540 --> 00:01:44,340
And if you get back to a C sharp file inside of the window definition you'll see how the class is being
19
00:01:44,340 --> 00:01:46,180
set up.
20
00:01:46,200 --> 00:01:53,460
We see these definition of a class and we are seeing the calculator dot main window which refers precisely
21
00:01:53,460 --> 00:01:58,890
to these class Node is that it is in say the namespace calculator and that is called main window that
22
00:01:58,890 --> 00:02:04,770
is the reason why it is the finest calculator the main window.
23
00:02:04,890 --> 00:02:12,030
Now here in the Sammul file we are not precisely the finding the other part of the class what is going
24
00:02:12,030 --> 00:02:19,860
on is that Visual Studio is automatically generating a file and in that file that by the way is another
25
00:02:19,860 --> 00:02:27,200
C-Sharp file defining any elements that we may be defining right here instead of some.
26
00:02:27,630 --> 00:02:29,550
So where is this file.
27
00:02:29,940 --> 00:02:33,490
Well we'll we'll actually have to search it up a bit.
28
00:02:33,510 --> 00:02:41,160
Gus Edis a little bit Hedon so you will have to navigate over here to your solution explorer and select
29
00:02:41,250 --> 00:02:49,980
the button to the top that says show all files and once you are selected you will see two new folders
30
00:02:50,040 --> 00:02:54,400
instead of your project that are by default hidden.
31
00:02:54,600 --> 00:02:57,780
So we don't have by default access to them.
32
00:02:58,150 --> 00:03:05,100
Would you then open or expand the OBD folder then in the debug folder and inside you will be able to
33
00:03:05,100 --> 00:03:12,030
find a bunch of water generated files including some that are called main window.
34
00:03:12,600 --> 00:03:16,180
These again are files generated by Visual Studio.
35
00:03:16,290 --> 00:03:23,400
The one that I wanted to focus on is the main window that the I don't see as you mentioned.
36
00:03:23,440 --> 00:03:25,280
These are fine.
37
00:03:25,530 --> 00:03:28,790
And as you can see it is smart as all generated.
38
00:03:29,150 --> 00:03:35,520
He says that this code was rated by at all and the changes in this file may cause incorrect behavior.
39
00:03:35,520 --> 00:03:41,520
So do not change anything unless you absolutely know what you're doing but the only thing that I want
40
00:03:41,520 --> 00:03:49,350
you to notice here is that if you go down these steal the calculator namespace just like we see on the
41
00:03:49,350 --> 00:03:55,650
other C-charge file and it easy steal the partial class mail window.
42
00:03:56,100 --> 00:04:00,400
So as you can see both are defined as public partial class main window.
43
00:04:00,630 --> 00:04:04,590
So both are defining the exact same class.
44
00:04:05,130 --> 00:04:13,590
And right below this definition we see some auto generated code that is label and that is resoled label.
45
00:04:14,130 --> 00:04:20,260
And these easy element that with the find in Sammul a label called withholder label.
46
00:04:20,850 --> 00:04:28,920
So these origin their rated code easy ones and makes it possible for us to access these element directly
47
00:04:28,920 --> 00:04:34,410
from the C-sharp file and of course access its properties and assign new values et cetera.
48
00:04:35,340 --> 00:04:41,850
So this was just a very brief lecture so you will understand a little bit about what is going on because
49
00:04:42,000 --> 00:04:44,460
this is not just some magic that is happening.
50
00:04:44,550 --> 00:04:50,740
There is actual code that makes the relationship between the salmon 1c share files possible.
51
00:04:51,090 --> 00:04:58,950
Basically some order generated code that is defining another other part of the same class is creating
52
00:04:58,950 --> 00:05:04,560
these elements and of course because these elements are in the same class they are accessible from both
53
00:05:04,560 --> 00:05:07,620
parts of the class definition.
54
00:05:08,010 --> 00:05:14,480
Hopefully now you see a bit more clear what is going on here and how the relationship works.
55
00:05:14,700 --> 00:05:20,640
Now in the next lecture we're going to introduce another way of communication between several and sharp
56
00:05:21,450 --> 00:05:27,300
that he's even hander's are going to respond to events that happen instead of the UI.
57
00:05:27,300 --> 00:05:32,760
For example the press of a button and executes some code in response.
6502
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.