Define a class in C# and create two instances of the class Part 3 – Create two instances from the class
Finally let’s create two instances from the class. Inside our TestPerson class and inside the Main method instantiate the instances by using the new keyword and call the constructor you wrote with the name paramater Now it’s time to return the instances value name property to the console. And here is the complete code. Time […]
Write click on the solution and create a new class and name the class file Set the access modifier to public. Create an auto-implemented read only property. Next add a constructor that takes one argument. Now in the next post we’ll instantiate two instances of our Person class.
Define a class in C# and create an instance of the class Part 1 – Create a new console app and rename the existing class
Let’s follow the Microsoft C# programming guide here. First off create a new .Net console application. Next go ahead and right click and rename the Program class to This also renames the class to TestPerson. Now in the next post we’ll create the new class!
Create a new console app and rename the existing class Create a new class Create two instances from the class
Something went wrong. Please refresh the page and/or try again.