Created
July 22, 2020 13:18
-
-
Save nanwang2016/b7648362775ad0f02de4c21d1949bc22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace TestFile | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Student UniStudent = new Student(); | |
UniStudent.Name = "Peter"; | |
UniStudent.Address = "Home"; | |
//Compiler will issue an error, as we attemp to read a set-only property | |
Console.WriteLine("Student's name is:" + UniStudent.Name); | |
} | |
} | |
class Student | |
{ | |
private string name; | |
private string address; | |
public string Name | |
{ | |
set | |
{ | |
name = value; | |
} | |
} | |
public string Address | |
{ | |
set | |
{ | |
address = value; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment