Scribe
Scribe

Ti piace? Rendi Scribe ancora migliore lasciando una recensione

Ottieni l'estensione Chrome

Sfoglia

  • Video Popolari
  • Video Recenti
  • Tutti i Canali

Strumenti Gratuiti

  • Scaricatore di Sottotitoli Video
  • Generatore di Timestamp Video
  • Riassuntore di Video
  • Contatore di Parole Video
  • Analizzatore di Titoli Video
  • Ricerca Trascrizioni Video
  • Analisi Video
  • Creatore di Capitoli Video
  • Generatore di Quiz Video
  • Chat con Video

Prodotto

  • Prezzi
  • Blog
  • Ottieni l'estensione Chrome

Developers

  • Transcript API
  • API Documentation

Legale

  • Termini
  • Privacy
  • Supporto
  • Mappa del sito

Copyright © 2026. Realizzato con ♥ da Scribe

— Se questo ha reso la tua vita più facile (o almeno un po' meno caotica), lascia una recensione! Promettiamo che ci renderà felici. 😊

Related Videos

Differences between Variable Instance and Reference | C#.NET Tutorial | Mr. Bangar Raju

Video thumbnail
156.48k3,403 Parole17m readGrade 18
Condividi
Channel
Naresh i Technologies
welcome to nervous technologies am bangarraju and in this video I will demonstrate you about the difference between variable of a class instance of a class and reference of a class these three are three important things what we are required to learn as a programmer what is it first one variable of a class second instance of a class and third the reference of the class so all these three things let us just try to understand first what is a class when we talk about a class many of the people say class is a collection of objects
collection of members something something ok I give it all these things but still first we just require to understand what is a class a class it's a user defined type it's a user different type what is it other different type string what is string generally we say string string is a data type we call string is a Dell type now understand the string is a data type budgeting was not born sting was also developed how is it developed it is developed as a class string is one predefined class in our libraries and remember and that
one we are calling as a data type now so the point to understand here is every class is a data type every class is going to be a data type some predefined classes user-defined classes or whatever it is but every class is going to be a data type or a in general simply speaking it is a type user defined type sorry user defined type so what is a class miss the first point understand it is a user defined data type or a user defined type and very importantly we can never consume a class directly how
to consume a class if you want to consume a class you are required to create a copy of it why to create a copy simple say int what is in term is everyone of you very cancer data type so it is a data type can I consume int like this never possible you cannot consume int like this so why because inte is only a blueprint int is only a blueprint for your particular data it does not have any memory allocation memory allocation will not be present for you here if you want any memory allocation you
should write int I is equals to 100 what is I I is a copy of type int I is going to be a copy of type end same very string is a called still hello is again the same point what is it invalid why what is string string is going to be a class and a class is a you will define the type you cannot consume it directly if you want to consume string yes is equals to health so what is s is a copy s is a copy of type string I is a copy
of type int how you can understand this you know to build a house we require a plan for a house can we build a house without a plan not possible so every house requires a plan same as the thing I am telling you here what is it this is the plan of your house okay and this is the constructor house if you want to live you require a constructor house C to build your house you enter an architect architect to given your plan for the house can you live in the plan never possible so if
you want to really live in want to require a house which is constructed based on the plan exactly into AI what is int int is the plan of a house and I is the constructor house so that's why culling into I is equals 200 so this is you now this is you the value you you are living in a constructor house you cannot live in a plan of the house not possible exactly the same thing I'm telling you here also what is it this again the plan of a house you cannot live in it what
I require a constructor house this is the constructor house so a data type is always a plan and a copy of the data type is an implementation for the plan that is how you can just understand so yes is a copy of type string same as that every class what we are defining right now string is also one class no issue every class whatever we are going to define right now is a new data type or it is a new type to consume that what you should do now create a copy of it until and
unless you create a copy of it memory will not be allocated so if the memory has to be allocated you are required to first create a copy of the type so that is a very important rule in our application development or in our programming to define a class is not a big deal but the consuming the class is important how to consume a class by creating a copy of it let me show you practical I'll open visual studio a new project a console application and I will call it as a does project I created a
project called as a test project fine open the project called as test project in this I have a class called program I want to rename this class just I want to rename this class naming it as first naming the classes first no issues even though you have the same what I want to change the name here as first so let me open the solution Explorer rename this gasps rename first it'll ask you renaming everything in the project related to program suggests say s and your class name also get change it to first fine so right
now we have a class here called as first well and good now in this class I will only declare a variable int Y X is equals to 100 index is equal to hundred and now I want to come to main now and I want to print the value of the X console dot write line y X console dot write line X but I will get an error if I run the code watch if at all I'm going to run this code I will have an error yeah there is an error why and where we have
an error the error is going to be present for you when you are trying to print the value of x y the reason is X is a instance member or a non-static member X is non-static memo and you cannot access the non-static members of a class from static blocks you can never do it see the main is a static block but X is not declared static if not declared static and non-static non-static members of a class cannot be accessed from the static blocks so we cannot print the x value here so if you want to
print the x value what you require to do now is create the instance of your class create the instance or a copy of this class how first F is equals to new first first F is equals to new foster so what is F F is the instance of your class your fizzell instance of your class our F is a copy of the class first F is a copy of the class first here we discussed what is SEO yes is a copy of type string and don't forget string is a class string is a class and
this is a copy of the type string exactly right now our class is first and F is a copy of class first and that copy is what we are calling as instance of the class and the memory is allocated for that instances now and the instances of a class can be created only by using new keyword when you're working with your dotnet the instance of a class can be created by using the new keyword we should use a new keyboard for creating the instance of the class so when I say first F is equals to
new first automatically the memory is allocated for this and now I should call it as F dot X now you can just check out the output will it will print the value to you okay so it printer the value of one read now the point you in just notice here is I can print the value only with the help of the class instance and instance of a class can be created only by using the new keyword see I'll delete this new first here simply I said first F what is F now F is only a
variable of the class F is called as a variable of a class what is variable of a class variable of a class may is a copy of a class that is not initialized it is not initialized what is not initialized yes it is simply considered as a uninitialized copy run and see you get an error and in the error you see it is telling you use of unassigned a local variable F so what is of F is a variable it is not an instance it is a variable and F dot X what is it f
dot X say you are trying to access a member by using a variable which is not possible so you can access the members only by using the instance instances of the class can be created only by using new keyword if you don't use a new that is not an instance it's just a variable and now see in the next line I'm writing F is equals to new faster now what is F F is again instance I just to broken the code and written in two separate statements that's all there's no difference between the two okay
what's this what is this you can create the instance of your particular class either like this so actually both these two statements are same no difference between them first F is equals to new first or first F F is equals to new first simple what is a feel efface instance of class and if you come here what is f your phase variable of class and the next line again yeah phase instance of class when my F is instance but in the first line we done declaration initialization on the same line but in the second case
declaration initialization separated that's it then no difference but AR finally a fizzy instance and while accessing the members you can access them by using that instance only okay right now again you can watch the output printing for you and this is what and now what is a variable of a class let's watch what is a variable of your class say variable state basically variable of the class and uninitialized to copy an uninitialized copy if you watch this picture in the first line when you said you have first ever fine when you said first step this
is a variable and there is no value no initialization nothing it is simply null in the next one when you say a physical still knew first F is equals to new foster so what is it now X is initialized to the variable X is initialized means memory allocation is done only after creating an instance remember that until and unless you create the instance memory allocation will not be done and instances can be created only by using the new keyword so this is what an instances okay so variable means what are the variable a copy of
the class that is not initialized a copy of the class that is not initialized now copy talking about the instance what is instance a copy of the class that is initialized by using the new keyword without using new you cannot create the instance of a class very important that is required for creating instance of a class and finally what is the reference of the class I'll demonstrate what are the reference of a class ok wait see if watch this if you watch this I can write this coding a simple single line so again I am
going to write it like this so simple I will write er first f1 any noises first f1 is equals to new first so what is F one instance of myclass the f1 is tensed and surplus okay now watch this first f2 what is have two variable upper class just now a talkative if I don't use a new keyword that just a variable so you have to is a variable of the class and using variables we can never call the members okay I want to initialize this if you want to initialize what you'll write F tau
is equals to new first you understand when you create one more time and you say F is equals new pasta another time the memory is allocated so two instances two times the memory is allocated okay you write on the same line nothing matter so now you are writing like this so what are these two instances and two times memory is allocated and see here F 2 is instance of class how many instances you create that many number of times memory will be allocated watch console dot write line F 2 dot X plus some space plus
dot X I am trying to print the both the x-values and it two times deeper into the x-values sorry here this is plus type mistake yeah two times it's printing you and these two are two separate copies I'll preview f1 dot X is equals to 200 and again I am trying to print you the things to watch out this is a proof to you to tell you both are two separate copies they are not one and the same see f1 sex modify f2 X did not modify and same way you try F 2 dot X
is equals to 300 and again reprint the value you can watch now f2 six is modified f1 Rallye remains same to you so the point I'm trying to tell you is you can create any number of instances to a class and every instance will have a separate memory allocation and the very important point to note here is the memory that is allocated for one instance is never shared with another instance in the sense any modifications performed on the members on one instance will never reflect it to the second instance watch it this can be you
can understand this very clearly two instance is created f1 f2 2 times memory is allocated in the first step you modified f1 X value to 200 and that did not reflect to f2 and in the second step you modified f2 X to 300 that will not reflect the f1 the changes will never reflect at all that is the beauty that is the beauty of your object-oriented programming that's basically security what's it every instance is unique of itself the changes made on one instance will never reflect to another instance ok fine so this is all about
our instances of a class well and good now let's also talk about what is the reference of the class we understood variable variable means copy of a class not initialized instance copy of a class that is initialized by using the new keyword now let me tell you what is a reference of class ok watch have a look let me comment all this code so right now f 1 f 2 both are two instances and now if at all I'm just going to delete this you have to is it variable of the class okay and now
I can initialize by using new AF first in the next line or same line I can initialize like this also I can initialize like this also so f 2 is initialized again how is it initialized by an existing instance and what is f 2 you know the F 2 is reference of the class F 2 is a reference of the class simply speaking F 2 is a pointer to F 1 F 2 is a pointer to F 1 basically okay so you have to doesn't have separate memory allocation then F 1 F 2 will be
consuming the same memory to you in this context both of them will be consuming the same memory I will preview watch first you have 1 F 2 both will print the same output to you both of them are printing the same output okay and remember F 2 is initialized it is not uninitialized if it is an initialized means variable variable cannot be used for calling the members but references can be used for calling the members how do you differentiate a reference a reference is a copy of a class that is created by using existing instance
very importantly references will not have memory reference is only a pointer to a instance but references can be used to like instances watch F 1 dot X I'm modifying because F 1 F 2 are you accessing the same memory if you run and watch your output both are printing 202 you both are printing 200 to you in this context okay and in the same way if at all I'm just going to say F 2 dot X is equals to 300 you can again watch both are going to show you 300 so both are going to
show you the same values to you why both are accessing the same memory say this this picture will tell you clearly F 1 is your in stands for which the memory is allocated f2 is not an instance reference accessing the same memory of f1 that is a reason why in the first step when you make a modification to f1 and the value is modified for you under the memory and when you access the particular variable 3 of 2 you got the same and in the second step you made a modification of X through f2 but
the change is reflected to f1 that is what I references so generally many of the people are some small confusion with all these three things that I am glorifying variable a copy of a class that is not initialized instance a copy of a class that initialize by using the new keyword which has its own memory and never shared with another instance reference of a class what are the reference of a class a copy of the class that is initialized by using an existing instance by using an existing instance and references of a class will not
have any memory allocation they will be they will be sharing the same memory of the instance that is assigned for initializing initializing the variable okay so that is what exactly a copy of a class that is initialized by using an existing instance and references of class will not have any memory allocation they will be sharing the same memory of the instance that is assigned for initializing the variable so simply speaking the Friends of a class can be called as a pointer to the instance pointer to the instance and every modification we perform on the members
using instance reflects when we access those members through reference also and vice versa the changes will be reflecting for you to and fro to and fro the changes will be reflecting modifications made on the members are through instance reflects to reference modifications made through reference reflects to instance that is what exactly and don't forget references of a class can be used it just like instance of a class no difference okay but the thing is it doesn't have its own memory thank you for watching the video and for more videos please subscribe to our YouTube channel
nourish IT you
Video correlati
Access Specifiers in C#.Net | C#.Net Tutorial | Mr. Bangar Raju
29:05
Access Specifiers in C#.Net | C#.Net Tutor...
Naresh i Technologies
189,121 views
Constructors Part 4 | Static Constructors vs Non Static Constructor | Mr. Bangar Raju
24:21
Constructors Part 4 | Static Constructors ...
Naresh i Technologies
122,730 views
Inheritance - Part 1 | C#.NET Tutorial | Mr. Bangar Raju
37:26
Inheritance - Part 1 | C#.NET Tutorial | M...
Naresh i Technologies
262,969 views
Different kinds of Variables in a class | C#.NET Tutorial
36:02
Different kinds of Variables in a class | ...
Naresh i Technologies
141,764 views
Differences between String and StringBuilder in C#.Net | C#.NET Tutorial | Mr. Bangar Raju
18:32
Differences between String and StringBuild...
Naresh i Technologies
63,776 views
Types of Constructors in C#.NET Part 2 | C#.NET Tutorial | Mr. Bangar Raju
30:24
Types of Constructors in C#.NET Part 2 | C...
Naresh i Technologies
275,373 views
ArrayList details (Collection Framework)
32:52
ArrayList details (Collection Framework)
Durga Software Solutions
573,928 views
Polymorphism in C# Method Hiding | C#.NET Tutorial | Mr. Bangar Raju
27:30
Polymorphism in C# Method Hiding | C#.NET ...
Naresh i Technologies
95,563 views
Constructors in C#.NET Part 1 | C#.NET Tutorial | Mr. Bangar Raju
22:05
Constructors in C#.NET Part 1 | C#.NET Tut...
Naresh i Technologies
439,153 views
Difference between Interface and Absract Class
16:57
Difference between Interface and Absract C...
DURGA EDUCATION
968,418 views
Learn Python Programming Tutorial Online Training by Durga Sir On 26-01-2018
1:02:48
Learn Python Programming Tutorial Online T...
Durga Software Solutions
1,840,565 views
Polymorphism in C# Method Overriding | C#.NET Tutorial | Mr. Bangar Raju
22:15
Polymorphism in C# Method Overriding | C#....
Naresh i Technologies
153,657 views
Improve Your English || Learn English Through Story || Graded Reader || Think And speak in English
37:33
Improve Your English || Learn English Thro...
The Storytellers Hub
112 views
Introduction to LINQ in C# | LINQ (Language Integrated Quer) | C#.NET Tutorial | Mr. Bangar Raju
24:45
Introduction to LINQ in C# | LINQ (Languag...
Naresh i Technologies
150,194 views
HDFS Architecture
1:06:33
HDFS Architecture
Durga Software Solutions
719,087 views
Polymorphism in C#  Operator Overloading | C#.NET Tutorial | Mr. Bangar Raju
43:11
Polymorphism in C# Operator Overloading |...
Naresh i Technologies
93,680 views
AWS CEO on AI, Return-to-Office Policy and What’s Next in the Cloud | WSJ
25:59
AWS CEO on AI, Return-to-Office Policy and...
WSJ News
3,019 views
Interfaces in C# | Part 1 | C#.NET Tutorial | Mr. Bangar Raju
22:45
Interfaces in C# | Part 1 | C#.NET Tutoria...
Naresh i Technologies
173,256 views