diff --git a/chap5_essential_language_features/automatically_implemented_properties/Program.cs b/chap5_essential_language_features/automatically_implemented_properties/Program.cs new file mode 100644 index 0000000..41a85ff --- /dev/null +++ b/chap5_essential_language_features/automatically_implemented_properties/Program.cs @@ -0,0 +1,31 @@ +using System; + +namespace automatically_implemented_properties +{ + class Program + { + static void Main(string[] args) + { + // create a new Product object + Product myProduct = new Product(); + + // set the property value + myProduct.Name = "Kayak"; + + // get the property + string produtName = myProduct.Name; + Console.WriteLine("Product name: {0}", produtName); + } + } + + public class Product + { + private string name; + + public string Name + { + get { return name; } + set { name = value; } + } + } +} \ No newline at end of file diff --git a/chap5_essential_language_features/automatically_implemented_properties/automatically_implemented_properties.csproj b/chap5_essential_language_features/automatically_implemented_properties/automatically_implemented_properties.csproj new file mode 100644 index 0000000..9590466 --- /dev/null +++ b/chap5_essential_language_features/automatically_implemented_properties/automatically_implemented_properties.csproj @@ -0,0 +1,8 @@ + + + + Exe + net5.0 + + + diff --git a/chap5_essential_language_features/chap5_essential_language_features.sln b/chap5_essential_language_features/chap5_essential_language_features.sln new file mode 100644 index 0000000..14ab7e1 --- /dev/null +++ b/chap5_essential_language_features/chap5_essential_language_features.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "automatically_implemented_properties", "automatically_implemented_properties\automatically_implemented_properties.csproj", "{96E49340-18A4-48F0-A71F-D756FFFC27A5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {96E49340-18A4-48F0-A71F-D756FFFC27A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {96E49340-18A4-48F0-A71F-D756FFFC27A5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {96E49340-18A4-48F0-A71F-D756FFFC27A5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {96E49340-18A4-48F0-A71F-D756FFFC27A5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal