+ 1

what is the definition of instance?

I would like to know about use of instance

16th Sep 2016, 2:07 PM
venkata veerendra manikumar kancharla
venkata veerendra manikumar kancharla - avatar
3 Respostas
+ 2
You use an instance of a Class when you want to access a 'public' Class. This is done thru the process called: INSTANTIATION using the "new" keyword. by using this syntax: ClassName instanceVar = new ClassName(); For example: You want to generate a random number between 0-9. So all you have to do is instantiate the Random Class: Random rand = new Random(); then access the method that generates random integers: int randomInt = rand.Next(10); Usually, we instantiate a class so that we can use the methods inside it that are need for our program jusy like the example above.
16th Sep 2016, 6:21 PM
Erwin Mesias
Erwin Mesias - avatar
+ 1
Ok I agree what Mesias is saying. But there is something else to add up: C# is an Object Oriented Programming lenguage and when you instantiate a class, thats what you are dong, you are creating an object that you will use as a bridge to access the properties declared inside the class from which that object was created from. Also, note you dont allways have to create an object from a class in order to access that class properties, some classes allow you to do it withouth creating an object and those classes are called "static" classes and therefore all of its properties need to be static as well.
17th Sep 2016, 5:41 AM
Pablo Hernandez
0
To use a class, you have to instanciate an object of the class first. An instance of the class is an object of the class. https://en.wikipedia.org/wiki/Instance_(computer_science)
16th Sep 2016, 2:16 PM
Zen
Zen - avatar