General C# programming - Creating New Classes Flashcards
How would you create a new class called Weapons?
class Weapons { }
How would you set a new string property in the weapons class called Gun?
public string Gun {get;set;}
How would you set a new int property in the Weapons class called Ammo;
public int Ammo {get;set;}
How would you creat a new instance of the Weapons class in a seperate class?
Weapons myWeapon = new Weapons();
myWeapon = anything you want to name it.
How would you set the number of ammo from the Weapons class inside another class?
myWeapon.Ammo = 22;
What does the word abstract in the follow class mean?
abstract class Inventory{
}
The class is intended only to be a base class of other classes
what does sealed mean in the following example?
sealed class B {
}
prevents other classes from inheriting from it
override
extend or modify the abstract or virtual implementation of an inherited method, property, indexer, or event.