Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace csharp_youtube_tutorial
- {
- //User made class.
- class Person
- {
- //Acces modifiers: public, private, static. public members can be accessed by any class. private can be accessed only in the class the member is in! Static members i dont know really. :)
- public string name = "Charles";
- public int age = 34;
- public string usuall_emotion = "Happy";
- public void person_information()
- {
- Console.WriteLine("Name: " + name);
- Console.WriteLine("Age: " + age);
- Console.WriteLine("Ususall emotion: " + usuall_emotion);
- }
- }
- //Original class.
- class Program
- {
- public static void Main(string[] args)
- {
- Console.ForegroundColor = ConsoleColor.Red; //Just for stylish<--!-->
- Person person_object1 = new Person(); //Syntax for creating an object for a class.
- string x = person_object1.name; //object.member
- Console.WriteLine(x);
- person_object1.person_information(); //You can also acces methods form classes.
- Console.ReadKey(); //Press a key application ends. //Console[Class] ReadKey()[Function/Method]
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement