classes in c#
using System;
namespace classes
{
// access modifiers control how properties and methods are accessed
class Book
{
// TODO: "public" members and methods can be accessed by any other code
// Note: this is *NOT* the right way to expose internal data
string _name;
string _author;
int _pagecount;
public Book(string name, string author, int pages) {
_name = name;
_author = author;
_pagecount = pages;
}
public string GetDescription() {
return $"{_name} is by {_author} and has {_pagecount} pages";
}
// TODO: Member variables can be accessed via methods
}
}