basic question regarding objects in c# -


Hey guys, just start with C #. I had some doubts, really appreciate it if someone can help me

question # 1

  animal dog; Dogs = new animals ();  

What is the difference between the two lines mentioned above?


Question # 2

  Namespace proj1 {public class} form 1: form {man bob; Public Form 1 () {Incentive component (); Bob = new boy (); Bob Name = "bob"; }}  

When Form 1 class is instant, then constructor form 1 () is the first thing to run.

But how is the data of the class in the member's announcement, which can be executed before Bob = new man () boy Bob ??

Question 1:

  Animals dog; Dogs = new animals ();  

In the first line of this example, you are declaring a variable type of animal . This means that the name of this variable and its type will be emitted to the stack by the C # compiler as part of IL in the assembly, whatever you are currently in.

The second row is an interesting part in the second line, you are making a new example of type and the context of that example is specified by that dog variable The code that you created on the previous line is also emitted for assembly, but it represents the code that will be executed in execution time when this row is applicable.

Question 2:

  public class form1: form {guy bob; Public Form 1 () {Incentive component (); Bob = new boy (); Bob Name = "bob"; }}  

This example is a bit more interesting because in the example you are working with big concepts in the example Private area class Form1 - this is done differently than just declaring variables like your first question.

A field is a part of the type of situation that you are currently in. In other words, by declaring this variable in the current type of radius, you are indicating that this variable is a field and hence is part of the type of template. This means that this area has been declared for all examples of this type.

This means that Man Bob's announcement; before actually you bob field It is actually defined at the time of compilation because the compiler will throw this field in the form of a field and as a result of the assembly, metadata will also reflect this field. Since this field is defined at compile time, you can see why you are able to specify the context because the code which specifies the reference of the field does not execute until the code is running.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -