diff --git a/9781430248606.jpg b/9781430248606.jpg new file mode 100644 index 0000000..c2be719 Binary files /dev/null and b/9781430248606.jpg differ diff --git a/9781430248606_sourcecode/BookExamples.sln b/9781430248606_sourcecode/BookExamples.sln new file mode 100644 index 0000000..748b2a3 --- /dev/null +++ b/9781430248606_sourcecode/BookExamples.sln @@ -0,0 +1,258 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ch01", "Ch01\Ch01.csproj", "{49F8E9D5-92B3-4E2F-A488-0FC4E76D3038}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ch02", "Ch02\Ch02.csproj", "{BA648C1E-279B-4198-B305-2DF1C043CFA2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ch03", "Ch03\Ch03.csproj", "{490B178E-CAD9-49D9-8B0F-AD699E18FFBF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ch04", "Ch04\Ch04.csproj", "{D595E1D6-0386-47FF-98B6-1287D3D93ACF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ch05", "Ch05\Ch05.csproj", "{F41576AF-3F4C-4BE0-8A8C-42C5E6A2B8B4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ch06", "Ch06\Ch06.csproj", "{1ABE6AC4-49BD-425E-8C55-C31DC9709611}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ch07", "Ch07\Ch07.csproj", "{355AD8B6-3A7B-42D3-A769-1C5F2209F492}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ch08", "Ch08\Ch08.csproj", "{4C3FB5F4-D3A0-4568-8462-093C6D6D3F95}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ch09", "Ch09\Ch09.csproj", "{8D8C5025-7DE6-4199-BD89-2AA6D0F57FB6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ch10", "Ch10\Ch10.csproj", "{0B6F3810-D7CB-497A-923B-D38CF61EAD44}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ch11", "Ch11\Ch11.csproj", "{3E8C37A0-B67E-4B8D-8463-0E27AE5CC063}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ch12", "Ch12\Ch12.csproj", "{AECCD015-05F0-47E3-973F-156EB64C956A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ch13", "Ch13\Ch13.csproj", "{ACD755CA-C7A8-4059-9474-57AD95C0AA28}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ch14", "Ch14\Ch14.csproj", "{C31EF547-CA0A-477F-9A40-0D0347906E6B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ch01-ReIntroducing", "Ch01-ReIntroducing", "{2F410106-2CDD-4C1A-8449-BC9E06AD5886}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ch02-ObjectAndMemory", "Ch02-ObjectAndMemory", "{3E57FE21-AECC-4327-BE95-43864DD790DB}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ch03-Parameters", "Ch03-Parameters", "{EDA05F60-5857-413C-8BAD-D845BB838739}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ch04-Methods", "Ch04-Methods", "{7183C46F-6D61-4C9E-B8F3-88F47FE11523}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ch05-AutomaticProperty", "Ch05-AutomaticProperty", "{B4C4F036-1C5D-4A34-854C-A98E87898F42}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ch06-Enum", "Ch06-Enum", "{C274216E-04F5-4871-863A-04CB4F825D56}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ch07-Delegate", "Ch07-Delegate", "{7F9BB7BA-5123-446F-97E9-EFBF89C73F65}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ch08-Event", "Ch08-Event", "{922F7B36-6AA2-49AF-8B26-B230964880D5}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ch09-Iterator", "Ch09-Iterator", "{4E956EF3-0FEE-4279-B8C6-A5C7255F4F14}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ch10-String", "Ch10-String", "{67D52602-1F0E-44A8-AE39-30FFA8428F6F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ch11-Collections", "Ch11-Collections", "{DEC57D57-781A-4DFB-926B-933AB1F5CCE4}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ch12-Linq", "Ch12-Linq", "{13A08F52-15AC-4C93-933D-64356D5F8D28}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ch13-ExceptionManagement", "Ch13-ExceptionManagement", "{81E0DA60-44D3-4822-AABA-13B97AC18F0F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ch14-Async", "Ch14-Async", "{75D599C0-0785-4819-8A3A-948589B9CA5B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ch15-Diagonsis", "Ch15-Diagonsis", "{3969995B-7367-4CA7-84D7-026B0AEEE26F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CH08_GUI", "CH08_GUI\CH08_GUI.csproj", "{471B1E24-E545-4DDA-921E-A41BAD47490B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ch15", "Ch15\Ch15.csproj", "{36B857F9-F732-40C5-A582-95FEB9F485B0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0B6F3810-D7CB-497A-923B-D38CF61EAD44}.Debug|Any CPU.ActiveCfg = Debug|x86 + {0B6F3810-D7CB-497A-923B-D38CF61EAD44}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {0B6F3810-D7CB-497A-923B-D38CF61EAD44}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {0B6F3810-D7CB-497A-923B-D38CF61EAD44}.Debug|x86.ActiveCfg = Debug|x86 + {0B6F3810-D7CB-497A-923B-D38CF61EAD44}.Debug|x86.Build.0 = Debug|x86 + {0B6F3810-D7CB-497A-923B-D38CF61EAD44}.Release|Any CPU.ActiveCfg = Release|x86 + {0B6F3810-D7CB-497A-923B-D38CF61EAD44}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {0B6F3810-D7CB-497A-923B-D38CF61EAD44}.Release|Mixed Platforms.Build.0 = Release|x86 + {0B6F3810-D7CB-497A-923B-D38CF61EAD44}.Release|x86.ActiveCfg = Release|x86 + {0B6F3810-D7CB-497A-923B-D38CF61EAD44}.Release|x86.Build.0 = Release|x86 + {1ABE6AC4-49BD-425E-8C55-C31DC9709611}.Debug|Any CPU.ActiveCfg = Debug|x86 + {1ABE6AC4-49BD-425E-8C55-C31DC9709611}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {1ABE6AC4-49BD-425E-8C55-C31DC9709611}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {1ABE6AC4-49BD-425E-8C55-C31DC9709611}.Debug|x86.ActiveCfg = Debug|x86 + {1ABE6AC4-49BD-425E-8C55-C31DC9709611}.Debug|x86.Build.0 = Debug|x86 + {1ABE6AC4-49BD-425E-8C55-C31DC9709611}.Release|Any CPU.ActiveCfg = Release|x86 + {1ABE6AC4-49BD-425E-8C55-C31DC9709611}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {1ABE6AC4-49BD-425E-8C55-C31DC9709611}.Release|Mixed Platforms.Build.0 = Release|x86 + {1ABE6AC4-49BD-425E-8C55-C31DC9709611}.Release|x86.ActiveCfg = Release|x86 + {1ABE6AC4-49BD-425E-8C55-C31DC9709611}.Release|x86.Build.0 = Release|x86 + {355AD8B6-3A7B-42D3-A769-1C5F2209F492}.Debug|Any CPU.ActiveCfg = Debug|x86 + {355AD8B6-3A7B-42D3-A769-1C5F2209F492}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {355AD8B6-3A7B-42D3-A769-1C5F2209F492}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {355AD8B6-3A7B-42D3-A769-1C5F2209F492}.Debug|x86.ActiveCfg = Debug|x86 + {355AD8B6-3A7B-42D3-A769-1C5F2209F492}.Debug|x86.Build.0 = Debug|x86 + {355AD8B6-3A7B-42D3-A769-1C5F2209F492}.Release|Any CPU.ActiveCfg = Release|x86 + {355AD8B6-3A7B-42D3-A769-1C5F2209F492}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {355AD8B6-3A7B-42D3-A769-1C5F2209F492}.Release|Mixed Platforms.Build.0 = Release|x86 + {355AD8B6-3A7B-42D3-A769-1C5F2209F492}.Release|x86.ActiveCfg = Release|x86 + {355AD8B6-3A7B-42D3-A769-1C5F2209F492}.Release|x86.Build.0 = Release|x86 + {36B857F9-F732-40C5-A582-95FEB9F485B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {36B857F9-F732-40C5-A582-95FEB9F485B0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {36B857F9-F732-40C5-A582-95FEB9F485B0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {36B857F9-F732-40C5-A582-95FEB9F485B0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {36B857F9-F732-40C5-A582-95FEB9F485B0}.Debug|x86.ActiveCfg = Debug|Any CPU + {36B857F9-F732-40C5-A582-95FEB9F485B0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {36B857F9-F732-40C5-A582-95FEB9F485B0}.Release|Any CPU.Build.0 = Release|Any CPU + {36B857F9-F732-40C5-A582-95FEB9F485B0}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {36B857F9-F732-40C5-A582-95FEB9F485B0}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {36B857F9-F732-40C5-A582-95FEB9F485B0}.Release|x86.ActiveCfg = Release|Any CPU + {3E8C37A0-B67E-4B8D-8463-0E27AE5CC063}.Debug|Any CPU.ActiveCfg = Debug|x86 + {3E8C37A0-B67E-4B8D-8463-0E27AE5CC063}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {3E8C37A0-B67E-4B8D-8463-0E27AE5CC063}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {3E8C37A0-B67E-4B8D-8463-0E27AE5CC063}.Debug|x86.ActiveCfg = Debug|x86 + {3E8C37A0-B67E-4B8D-8463-0E27AE5CC063}.Debug|x86.Build.0 = Debug|x86 + {3E8C37A0-B67E-4B8D-8463-0E27AE5CC063}.Release|Any CPU.ActiveCfg = Release|x86 + {3E8C37A0-B67E-4B8D-8463-0E27AE5CC063}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {3E8C37A0-B67E-4B8D-8463-0E27AE5CC063}.Release|Mixed Platforms.Build.0 = Release|x86 + {3E8C37A0-B67E-4B8D-8463-0E27AE5CC063}.Release|x86.ActiveCfg = Release|x86 + {3E8C37A0-B67E-4B8D-8463-0E27AE5CC063}.Release|x86.Build.0 = Release|x86 + {471B1E24-E545-4DDA-921E-A41BAD47490B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {471B1E24-E545-4DDA-921E-A41BAD47490B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {471B1E24-E545-4DDA-921E-A41BAD47490B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {471B1E24-E545-4DDA-921E-A41BAD47490B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {471B1E24-E545-4DDA-921E-A41BAD47490B}.Debug|x86.ActiveCfg = Debug|Any CPU + {471B1E24-E545-4DDA-921E-A41BAD47490B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {471B1E24-E545-4DDA-921E-A41BAD47490B}.Release|Any CPU.Build.0 = Release|Any CPU + {471B1E24-E545-4DDA-921E-A41BAD47490B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {471B1E24-E545-4DDA-921E-A41BAD47490B}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {471B1E24-E545-4DDA-921E-A41BAD47490B}.Release|x86.ActiveCfg = Release|Any CPU + {490B178E-CAD9-49D9-8B0F-AD699E18FFBF}.Debug|Any CPU.ActiveCfg = Debug|x86 + {490B178E-CAD9-49D9-8B0F-AD699E18FFBF}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {490B178E-CAD9-49D9-8B0F-AD699E18FFBF}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {490B178E-CAD9-49D9-8B0F-AD699E18FFBF}.Debug|x86.ActiveCfg = Debug|x86 + {490B178E-CAD9-49D9-8B0F-AD699E18FFBF}.Debug|x86.Build.0 = Debug|x86 + {490B178E-CAD9-49D9-8B0F-AD699E18FFBF}.Release|Any CPU.ActiveCfg = Release|x86 + {490B178E-CAD9-49D9-8B0F-AD699E18FFBF}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {490B178E-CAD9-49D9-8B0F-AD699E18FFBF}.Release|Mixed Platforms.Build.0 = Release|x86 + {490B178E-CAD9-49D9-8B0F-AD699E18FFBF}.Release|x86.ActiveCfg = Release|x86 + {490B178E-CAD9-49D9-8B0F-AD699E18FFBF}.Release|x86.Build.0 = Release|x86 + {49F8E9D5-92B3-4E2F-A488-0FC4E76D3038}.Debug|Any CPU.ActiveCfg = Debug|x86 + {49F8E9D5-92B3-4E2F-A488-0FC4E76D3038}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {49F8E9D5-92B3-4E2F-A488-0FC4E76D3038}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {49F8E9D5-92B3-4E2F-A488-0FC4E76D3038}.Debug|x86.ActiveCfg = Debug|x86 + {49F8E9D5-92B3-4E2F-A488-0FC4E76D3038}.Debug|x86.Build.0 = Debug|x86 + {49F8E9D5-92B3-4E2F-A488-0FC4E76D3038}.Release|Any CPU.ActiveCfg = Release|x86 + {49F8E9D5-92B3-4E2F-A488-0FC4E76D3038}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {49F8E9D5-92B3-4E2F-A488-0FC4E76D3038}.Release|Mixed Platforms.Build.0 = Release|x86 + {49F8E9D5-92B3-4E2F-A488-0FC4E76D3038}.Release|x86.ActiveCfg = Release|x86 + {49F8E9D5-92B3-4E2F-A488-0FC4E76D3038}.Release|x86.Build.0 = Release|x86 + {4C3FB5F4-D3A0-4568-8462-093C6D6D3F95}.Debug|Any CPU.ActiveCfg = Debug|x86 + {4C3FB5F4-D3A0-4568-8462-093C6D6D3F95}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {4C3FB5F4-D3A0-4568-8462-093C6D6D3F95}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {4C3FB5F4-D3A0-4568-8462-093C6D6D3F95}.Debug|x86.ActiveCfg = Debug|x86 + {4C3FB5F4-D3A0-4568-8462-093C6D6D3F95}.Debug|x86.Build.0 = Debug|x86 + {4C3FB5F4-D3A0-4568-8462-093C6D6D3F95}.Release|Any CPU.ActiveCfg = Release|x86 + {4C3FB5F4-D3A0-4568-8462-093C6D6D3F95}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {4C3FB5F4-D3A0-4568-8462-093C6D6D3F95}.Release|Mixed Platforms.Build.0 = Release|x86 + {4C3FB5F4-D3A0-4568-8462-093C6D6D3F95}.Release|x86.ActiveCfg = Release|x86 + {4C3FB5F4-D3A0-4568-8462-093C6D6D3F95}.Release|x86.Build.0 = Release|x86 + {8D8C5025-7DE6-4199-BD89-2AA6D0F57FB6}.Debug|Any CPU.ActiveCfg = Debug|x86 + {8D8C5025-7DE6-4199-BD89-2AA6D0F57FB6}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {8D8C5025-7DE6-4199-BD89-2AA6D0F57FB6}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {8D8C5025-7DE6-4199-BD89-2AA6D0F57FB6}.Debug|x86.ActiveCfg = Debug|x86 + {8D8C5025-7DE6-4199-BD89-2AA6D0F57FB6}.Debug|x86.Build.0 = Debug|x86 + {8D8C5025-7DE6-4199-BD89-2AA6D0F57FB6}.Release|Any CPU.ActiveCfg = Release|x86 + {8D8C5025-7DE6-4199-BD89-2AA6D0F57FB6}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {8D8C5025-7DE6-4199-BD89-2AA6D0F57FB6}.Release|Mixed Platforms.Build.0 = Release|x86 + {8D8C5025-7DE6-4199-BD89-2AA6D0F57FB6}.Release|x86.ActiveCfg = Release|x86 + {8D8C5025-7DE6-4199-BD89-2AA6D0F57FB6}.Release|x86.Build.0 = Release|x86 + {ACD755CA-C7A8-4059-9474-57AD95C0AA28}.Debug|Any CPU.ActiveCfg = Debug|x86 + {ACD755CA-C7A8-4059-9474-57AD95C0AA28}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {ACD755CA-C7A8-4059-9474-57AD95C0AA28}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {ACD755CA-C7A8-4059-9474-57AD95C0AA28}.Debug|x86.ActiveCfg = Debug|x86 + {ACD755CA-C7A8-4059-9474-57AD95C0AA28}.Debug|x86.Build.0 = Debug|x86 + {ACD755CA-C7A8-4059-9474-57AD95C0AA28}.Release|Any CPU.ActiveCfg = Release|x86 + {ACD755CA-C7A8-4059-9474-57AD95C0AA28}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {ACD755CA-C7A8-4059-9474-57AD95C0AA28}.Release|Mixed Platforms.Build.0 = Release|x86 + {ACD755CA-C7A8-4059-9474-57AD95C0AA28}.Release|x86.ActiveCfg = Release|x86 + {ACD755CA-C7A8-4059-9474-57AD95C0AA28}.Release|x86.Build.0 = Release|x86 + {AECCD015-05F0-47E3-973F-156EB64C956A}.Debug|Any CPU.ActiveCfg = Debug|x86 + {AECCD015-05F0-47E3-973F-156EB64C956A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {AECCD015-05F0-47E3-973F-156EB64C956A}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {AECCD015-05F0-47E3-973F-156EB64C956A}.Debug|x86.ActiveCfg = Debug|x86 + {AECCD015-05F0-47E3-973F-156EB64C956A}.Debug|x86.Build.0 = Debug|x86 + {AECCD015-05F0-47E3-973F-156EB64C956A}.Release|Any CPU.ActiveCfg = Release|x86 + {AECCD015-05F0-47E3-973F-156EB64C956A}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {AECCD015-05F0-47E3-973F-156EB64C956A}.Release|Mixed Platforms.Build.0 = Release|x86 + {AECCD015-05F0-47E3-973F-156EB64C956A}.Release|x86.ActiveCfg = Release|x86 + {AECCD015-05F0-47E3-973F-156EB64C956A}.Release|x86.Build.0 = Release|x86 + {BA648C1E-279B-4198-B305-2DF1C043CFA2}.Debug|Any CPU.ActiveCfg = Debug|x86 + {BA648C1E-279B-4198-B305-2DF1C043CFA2}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {BA648C1E-279B-4198-B305-2DF1C043CFA2}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {BA648C1E-279B-4198-B305-2DF1C043CFA2}.Debug|x86.ActiveCfg = Debug|x86 + {BA648C1E-279B-4198-B305-2DF1C043CFA2}.Debug|x86.Build.0 = Debug|x86 + {BA648C1E-279B-4198-B305-2DF1C043CFA2}.Release|Any CPU.ActiveCfg = Release|x86 + {BA648C1E-279B-4198-B305-2DF1C043CFA2}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {BA648C1E-279B-4198-B305-2DF1C043CFA2}.Release|Mixed Platforms.Build.0 = Release|x86 + {BA648C1E-279B-4198-B305-2DF1C043CFA2}.Release|x86.ActiveCfg = Release|x86 + {BA648C1E-279B-4198-B305-2DF1C043CFA2}.Release|x86.Build.0 = Release|x86 + {C31EF547-CA0A-477F-9A40-0D0347906E6B}.Debug|Any CPU.ActiveCfg = Debug|x86 + {C31EF547-CA0A-477F-9A40-0D0347906E6B}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {C31EF547-CA0A-477F-9A40-0D0347906E6B}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {C31EF547-CA0A-477F-9A40-0D0347906E6B}.Debug|x86.ActiveCfg = Debug|x86 + {C31EF547-CA0A-477F-9A40-0D0347906E6B}.Debug|x86.Build.0 = Debug|x86 + {C31EF547-CA0A-477F-9A40-0D0347906E6B}.Release|Any CPU.ActiveCfg = Release|x86 + {C31EF547-CA0A-477F-9A40-0D0347906E6B}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {C31EF547-CA0A-477F-9A40-0D0347906E6B}.Release|Mixed Platforms.Build.0 = Release|x86 + {C31EF547-CA0A-477F-9A40-0D0347906E6B}.Release|x86.ActiveCfg = Release|x86 + {C31EF547-CA0A-477F-9A40-0D0347906E6B}.Release|x86.Build.0 = Release|x86 + {D595E1D6-0386-47FF-98B6-1287D3D93ACF}.Debug|Any CPU.ActiveCfg = Debug|x86 + {D595E1D6-0386-47FF-98B6-1287D3D93ACF}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {D595E1D6-0386-47FF-98B6-1287D3D93ACF}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {D595E1D6-0386-47FF-98B6-1287D3D93ACF}.Debug|x86.ActiveCfg = Debug|x86 + {D595E1D6-0386-47FF-98B6-1287D3D93ACF}.Debug|x86.Build.0 = Debug|x86 + {D595E1D6-0386-47FF-98B6-1287D3D93ACF}.Release|Any CPU.ActiveCfg = Release|x86 + {D595E1D6-0386-47FF-98B6-1287D3D93ACF}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {D595E1D6-0386-47FF-98B6-1287D3D93ACF}.Release|Mixed Platforms.Build.0 = Release|x86 + {D595E1D6-0386-47FF-98B6-1287D3D93ACF}.Release|x86.ActiveCfg = Release|x86 + {D595E1D6-0386-47FF-98B6-1287D3D93ACF}.Release|x86.Build.0 = Release|x86 + {F41576AF-3F4C-4BE0-8A8C-42C5E6A2B8B4}.Debug|Any CPU.ActiveCfg = Debug|x86 + {F41576AF-3F4C-4BE0-8A8C-42C5E6A2B8B4}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {F41576AF-3F4C-4BE0-8A8C-42C5E6A2B8B4}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {F41576AF-3F4C-4BE0-8A8C-42C5E6A2B8B4}.Debug|x86.ActiveCfg = Debug|x86 + {F41576AF-3F4C-4BE0-8A8C-42C5E6A2B8B4}.Debug|x86.Build.0 = Debug|x86 + {F41576AF-3F4C-4BE0-8A8C-42C5E6A2B8B4}.Release|Any CPU.ActiveCfg = Release|x86 + {F41576AF-3F4C-4BE0-8A8C-42C5E6A2B8B4}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {F41576AF-3F4C-4BE0-8A8C-42C5E6A2B8B4}.Release|Mixed Platforms.Build.0 = Release|x86 + {F41576AF-3F4C-4BE0-8A8C-42C5E6A2B8B4}.Release|x86.ActiveCfg = Release|x86 + {F41576AF-3F4C-4BE0-8A8C-42C5E6A2B8B4}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {0B6F3810-D7CB-497A-923B-D38CF61EAD44} = {67D52602-1F0E-44A8-AE39-30FFA8428F6F} + {1ABE6AC4-49BD-425E-8C55-C31DC9709611} = {C274216E-04F5-4871-863A-04CB4F825D56} + {355AD8B6-3A7B-42D3-A769-1C5F2209F492} = {7F9BB7BA-5123-446F-97E9-EFBF89C73F65} + {36B857F9-F732-40C5-A582-95FEB9F485B0} = {3969995B-7367-4CA7-84D7-026B0AEEE26F} + {3E8C37A0-B67E-4B8D-8463-0E27AE5CC063} = {DEC57D57-781A-4DFB-926B-933AB1F5CCE4} + {471B1E24-E545-4DDA-921E-A41BAD47490B} = {922F7B36-6AA2-49AF-8B26-B230964880D5} + {490B178E-CAD9-49D9-8B0F-AD699E18FFBF} = {EDA05F60-5857-413C-8BAD-D845BB838739} + {49F8E9D5-92B3-4E2F-A488-0FC4E76D3038} = {2F410106-2CDD-4C1A-8449-BC9E06AD5886} + {4C3FB5F4-D3A0-4568-8462-093C6D6D3F95} = {922F7B36-6AA2-49AF-8B26-B230964880D5} + {8D8C5025-7DE6-4199-BD89-2AA6D0F57FB6} = {4E956EF3-0FEE-4279-B8C6-A5C7255F4F14} + {ACD755CA-C7A8-4059-9474-57AD95C0AA28} = {81E0DA60-44D3-4822-AABA-13B97AC18F0F} + {AECCD015-05F0-47E3-973F-156EB64C956A} = {13A08F52-15AC-4C93-933D-64356D5F8D28} + {BA648C1E-279B-4198-B305-2DF1C043CFA2} = {3E57FE21-AECC-4327-BE95-43864DD790DB} + {C31EF547-CA0A-477F-9A40-0D0347906E6B} = {75D599C0-0785-4819-8A3A-948589B9CA5B} + {D595E1D6-0386-47FF-98B6-1287D3D93ACF} = {7183C46F-6D61-4C9E-B8F3-88F47FE11523} + {F41576AF-3F4C-4BE0-8A8C-42C5E6A2B8B4} = {B4C4F036-1C5D-4A34-854C-A98E87898F42} + EndGlobalSection +EndGlobal diff --git a/9781430248606_sourcecode/BookExamples.sln.docstates.suo b/9781430248606_sourcecode/BookExamples.sln.docstates.suo new file mode 100644 index 0000000..b4a66c2 Binary files /dev/null and b/9781430248606_sourcecode/BookExamples.sln.docstates.suo differ diff --git a/9781430248606_sourcecode/BookExamples.suo b/9781430248606_sourcecode/BookExamples.suo new file mode 100644 index 0000000..3f8e7c9 Binary files /dev/null and b/9781430248606_sourcecode/BookExamples.suo differ diff --git a/9781430248606_sourcecode/BookExamples.v11.suo b/9781430248606_sourcecode/BookExamples.v11.suo new file mode 100644 index 0000000..6c7c9c3 Binary files /dev/null and b/9781430248606_sourcecode/BookExamples.v11.suo differ diff --git a/9781430248606_sourcecode/CH08_GUI/App.config b/9781430248606_sourcecode/CH08_GUI/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/9781430248606_sourcecode/CH08_GUI/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/CH08_GUI/CH08_GUI.csproj b/9781430248606_sourcecode/CH08_GUI/CH08_GUI.csproj new file mode 100644 index 0000000..e9125cc --- /dev/null +++ b/9781430248606_sourcecode/CH08_GUI/CH08_GUI.csproj @@ -0,0 +1,88 @@ + + + + + Debug + AnyCPU + {471B1E24-E545-4DDA-921E-A41BAD47490B} + WinExe + Properties + CH08_GUI + CH08_GUI + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + Form + + + frmMain.cs + + + + + frmMain.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/CH08_GUI/Program.cs b/9781430248606_sourcecode/CH08_GUI/Program.cs new file mode 100644 index 0000000..64f7e8b --- /dev/null +++ b/9781430248606_sourcecode/CH08_GUI/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace CH08_GUI +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new frmMain()); + } + } +} diff --git a/9781430248606_sourcecode/CH08_GUI/Properties/AssemblyInfo.cs b/9781430248606_sourcecode/CH08_GUI/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b8bf1b2 --- /dev/null +++ b/9781430248606_sourcecode/CH08_GUI/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CH08_GUI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CH08_GUI")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e07feae8-a359-4660-9f5d-be1c4220e653")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9781430248606_sourcecode/CH08_GUI/Properties/Resources.Designer.cs b/9781430248606_sourcecode/CH08_GUI/Properties/Resources.Designer.cs new file mode 100644 index 0000000..5cb7070 --- /dev/null +++ b/9781430248606_sourcecode/CH08_GUI/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.17626 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace CH08_GUI.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CH08_GUI.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/9781430248606_sourcecode/CH08_GUI/Properties/Resources.resx b/9781430248606_sourcecode/CH08_GUI/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/9781430248606_sourcecode/CH08_GUI/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/9781430248606_sourcecode/CH08_GUI/Properties/Settings.Designer.cs b/9781430248606_sourcecode/CH08_GUI/Properties/Settings.Designer.cs new file mode 100644 index 0000000..ba78347 --- /dev/null +++ b/9781430248606_sourcecode/CH08_GUI/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.17626 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace CH08_GUI.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/9781430248606_sourcecode/CH08_GUI/Properties/Settings.settings b/9781430248606_sourcecode/CH08_GUI/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/9781430248606_sourcecode/CH08_GUI/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/9781430248606_sourcecode/CH08_GUI/bin/Debug/CH08_GUI.vshost.exe b/9781430248606_sourcecode/CH08_GUI/bin/Debug/CH08_GUI.vshost.exe new file mode 100644 index 0000000..212bd7f Binary files /dev/null and b/9781430248606_sourcecode/CH08_GUI/bin/Debug/CH08_GUI.vshost.exe differ diff --git a/9781430248606_sourcecode/CH08_GUI/bin/Debug/CH08_GUI.vshost.exe.config b/9781430248606_sourcecode/CH08_GUI/bin/Debug/CH08_GUI.vshost.exe.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/9781430248606_sourcecode/CH08_GUI/bin/Debug/CH08_GUI.vshost.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/CH08_GUI/bin/Debug/CH08_GUI.vshost.exe.manifest b/9781430248606_sourcecode/CH08_GUI/bin/Debug/CH08_GUI.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/9781430248606_sourcecode/CH08_GUI/bin/Debug/CH08_GUI.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/9781430248606_sourcecode/CH08_GUI/frmMain.Designer.cs b/9781430248606_sourcecode/CH08_GUI/frmMain.Designer.cs new file mode 100644 index 0000000..4f4230d --- /dev/null +++ b/9781430248606_sourcecode/CH08_GUI/frmMain.Designer.cs @@ -0,0 +1,18 @@ +namespace CH08_GUI +{ + partial class frmMain + { + /* code removed */ + private void InitializeComponent() + { + this.btnGenerate = new System.Windows.Forms.Button(); + /* code removed */ + this.btnGenerate.Click += new System.EventHandler(this.btnGenerate_Click); + /* code removed */ + } + + private System.Windows.Forms.Button btnGenerate; + private System.Windows.Forms.Label lblGuid; + } +} + diff --git a/9781430248606_sourcecode/CH08_GUI/frmMain.cs b/9781430248606_sourcecode/CH08_GUI/frmMain.cs new file mode 100644 index 0000000..3d9f165 --- /dev/null +++ b/9781430248606_sourcecode/CH08_GUI/frmMain.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace CH08_GUI +{ + public partial class frmMain : Form + { + public frmMain() + { + InitializeComponent(); + } + + private void btnGenerate_Click(object sender, EventArgs e) + { + lblGuid.Text = Guid.NewGuid().ToString("N"); + } + } +} diff --git a/9781430248606_sourcecode/CH08_GUI/frmMain.resx b/9781430248606_sourcecode/CH08_GUI/frmMain.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/9781430248606_sourcecode/CH08_GUI/frmMain.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/9781430248606_sourcecode/CH08_GUI/obj/Debug/CH08_GUI.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/CH08_GUI/obj/Debug/CH08_GUI.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..e255c83 --- /dev/null +++ b/9781430248606_sourcecode/CH08_GUI/obj/Debug/CH08_GUI.csproj.FileListAbsolute.txt @@ -0,0 +1,9 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\CH08_GUI\bin\Debug\CH08_GUI.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\CH08_GUI\bin\Debug\CH08_GUI.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\CH08_GUI\bin\Debug\CH08_GUI.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\CH08_GUI\obj\Debug\CH08_GUI.csprojResolveAssemblyReference.cache +J:\Book\ExpertC#2012\SourceCode\BookExamples\CH08_GUI\obj\Debug\CH08_GUI.frmMain.resources +J:\Book\ExpertC#2012\SourceCode\BookExamples\CH08_GUI\obj\Debug\CH08_GUI.Properties.Resources.resources +J:\Book\ExpertC#2012\SourceCode\BookExamples\CH08_GUI\obj\Debug\CH08_GUI.csproj.GenerateResource.Cache +J:\Book\ExpertC#2012\SourceCode\BookExamples\CH08_GUI\obj\Debug\CH08_GUI.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\CH08_GUI\obj\Debug\CH08_GUI.pdb diff --git a/9781430248606_sourcecode/CH08_GUI/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/9781430248606_sourcecode/CH08_GUI/obj/Debug/DesignTimeResolveAssemblyReferences.cache new file mode 100644 index 0000000..a07a90e Binary files /dev/null and b/9781430248606_sourcecode/CH08_GUI/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/9781430248606_sourcecode/CH08_GUI/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/CH08_GUI/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..a8d12f8 Binary files /dev/null and b/9781430248606_sourcecode/CH08_GUI/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/CH08_GUI/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/9781430248606_sourcecode/CH08_GUI/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/CH08_GUI/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/9781430248606_sourcecode/CH08_GUI/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch01/Ch01.csproj b/9781430248606_sourcecode/Ch01/Ch01.csproj new file mode 100644 index 0000000..53c315e --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Ch01.csproj @@ -0,0 +1,120 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {49F8E9D5-92B3-4E2F-A488-0FC4E76D3038} + Exe + Properties + Ch01 + Ch01 + v4.5 + + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch01/Listing 1-1.cs b/9781430248606_sourcecode/Ch01/Listing 1-1.cs new file mode 100644 index 0000000..3b3f8fd --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-1.cs @@ -0,0 +1,31 @@ +//using System; /* importing namespace */ + +//namespace Ch01 /* namespace declaration */ +//{ +// class Program /* class declaration*/ +// { +// static void Main(string[] args) /* method declaration */ +// { +// PowerGenerator pg = new PowerGenerator(); +// pg.ProcessPower(); +// } /* end of method declaration */ +// } /* end of class declaration */ + +// public class PowerGenerator +// { +// const int limit = 3; /* constant declaration */ +// const string +// original = "Original number", +// square = "Square number"; + +// public void ProcessPower() +// { +// Console.WriteLine("{0,16}{1,20}", +// original, square); /* statement*/ +// for (int i = 0; i <= limit; ++i) /* iteration statement*/ +// { +// Console.Write("{0,10}{1,20}\n", i, Math.Pow(i, 2)); +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-10.cs b/9781430248606_sourcecode/Ch01/Listing 1-10.cs new file mode 100644 index 0000000..15c4590 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-10.cs @@ -0,0 +1,19 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Book book = default(Book); /* null */ +// int i = default(int); /* 0 */ +// float f = default(float); /* 0.0 */ +// char c = default(char); /* '\0' */ +// bool b = default(bool); /* false */ +// Planets p = default(Planets); /* Earth */ +// } +// } + +// class Book { } /* a reference type Book declaration */ +// enum Planets { Earth = 0 } /* enum declaration */ +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-11.cs b/9781430248606_sourcecode/Ch01/Listing 1-11.cs new file mode 100644 index 0000000..097334c --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-11.cs @@ -0,0 +1,21 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Converter converter = new Converter(); +// converter.ConvertAndIncrease(10); +// } +// } + +// public class Converter +// { +// public int ConvertAndIncrease(int baseValue) +// { +// int increaseFactor = 10; +// return baseValue + increaseFactor; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-12.cs b/9781430248606_sourcecode/Ch01/Listing 1-12.cs new file mode 100644 index 0000000..5890130 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-12.cs @@ -0,0 +1,21 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// public static int X = 100; /* Static variable */ + +// static void Main(string[] args) +// { +// Console.Write("{0}\t", X); /* 100 */ +// Program.X = 200; /* This change affect globally */ +// Console.Write("{0}\t", X); /* 200 */ +// Show(); +// } + +// static void Show() +// { +// Console.Write("{0}\t", Program.X); /* 200 */ +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-13.cs b/9781430248606_sourcecode/Ch01/Listing 1-13.cs new file mode 100644 index 0000000..a646a11 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-13.cs @@ -0,0 +1,24 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// AClass anObject = new AClass(); +// Console.ReadLine(); +// } +// } +// public class AClass +// { +// public int X; +// public AClass() +// { +// Console.WriteLine("Initial value of the X :{0}", X); +// X = 100; +// Console.WriteLine("Updated value of the X :{0}", X); +// MethodA(); +// } +// public void MethodA() { } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-14.cs b/9781430248606_sourcecode/Ch01/Listing 1-14.cs new file mode 100644 index 0000000..f2a5eaf --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-14.cs @@ -0,0 +1,17 @@ +//using System; + +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int x; +// WithOutInParameter(out x); +// Console.WriteLine(x); /* 100 */ +// } + +// static void WithOutInParameter(out int a) +// { a = 100; } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-15.cs b/9781430248606_sourcecode/Ch01/Listing 1-15.cs new file mode 100644 index 0000000..60d92eb --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-15.cs @@ -0,0 +1,38 @@ +//using System; +//using System.IO; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// AClass aClass = new AClass(); +// aClass.MethodA(); +// Console.ReadLine(); +// } +// } + +// public class AClass +// { +// public void MethodA() +// { +// int a = 10; +// switch (a) +// { +// case 7: +// Console.WriteLine("..."); +// break; +// case 10: +// int b = 10; +// Console.WriteLine(b); +// break; +// default: Console.WriteLine("Default"); break; +// } +// for (int i = 0; i < 5; ++i) ; +// using (MemoryStream ms = new MemoryStream()) +// { +// ; /*Doing nothing*/ +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-18.cs b/9781430248606_sourcecode/Ch01/Listing 1-18.cs new file mode 100644 index 0000000..14e5457 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-18.cs @@ -0,0 +1,24 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// /* Initializes with 100 */ +// int x = 100; +// Console.WriteLine("Before method call :\t{0}", x); + +// /* pass ass value to the Increment method*/ +// Increment(x); +// Console.WriteLine("After method call :\t{0}", x); +// } + +// /* a is the parameter for the MethodA*/ +// static void Increment(int a) +// { +// ++a; +// Console.WriteLine("Incremented value :\t{0}", a); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-19.cs b/9781430248606_sourcecode/Ch01/Listing 1-19.cs new file mode 100644 index 0000000..264ddda --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-19.cs @@ -0,0 +1,18 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int x = 100; /* Needs to initialize x */ +// Console.WriteLine(x); /* 100 */ +// Increment(ref x); /* pass the location (0x052de8b4) of the x */ +// Console.WriteLine(x); /* 101 */ +// } +// static void Increment(ref int a) /* a pointing to the same memory +// * location as x (0x052de8b4) +// * of Main method */ +// { ++a; } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-2.cs b/9781430248606_sourcecode/Ch01/Listing 1-2.cs new file mode 100644 index 0000000..280b109 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-2.cs @@ -0,0 +1,20 @@ +//using System; + +///* Ch01 is the identifier to name the namespace*/ +//namespace Ch01 +//{ +// /* Program is the identifier to name the class */ +// class Program +// { +// /* Main is the identifier to name the method */ +// static void Main(string[] args) +// { +// /* a and _a is the identifier to name the variable */ +// int a = 10, _a = 20; +// /* Verbatim identifier - start with an @ prefix */ +// int @int = 10; + +// Console.WriteLine("{0}\t{1}\t{2}", a, _a, @int); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-20.cs b/9781430248606_sourcecode/Ch01/Listing 1-20.cs new file mode 100644 index 0000000..264ddda --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-20.cs @@ -0,0 +1,18 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int x = 100; /* Needs to initialize x */ +// Console.WriteLine(x); /* 100 */ +// Increment(ref x); /* pass the location (0x052de8b4) of the x */ +// Console.WriteLine(x); /* 101 */ +// } +// static void Increment(ref int a) /* a pointing to the same memory +// * location as x (0x052de8b4) +// * of Main method */ +// { ++a; } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-21.cs b/9781430248606_sourcecode/Ch01/Listing 1-21.cs new file mode 100644 index 0000000..1059006 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-21.cs @@ -0,0 +1,20 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// string[] planets = { "Jupiter", "\n", "Pallas" }; +// Console.WriteLine("{0}", ConcatStrings(planets)); +// } + +// static string ConcatStrings(params string[] items) +// { +// string result = default(string); +// foreach (string item in items) +// { result = string.Concat(result, item); } +// return result; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-22.cs b/9781430248606_sourcecode/Ch01/Listing 1-22.cs new file mode 100644 index 0000000..5ec079c --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-22.cs @@ -0,0 +1,17 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Show(); /* Please specify message */ +// Show("Message set"); /* Message set */ +// } + +// static void Show(string message = "Please specify message") +// { +// Console.WriteLine(message); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-23.cs b/9781430248606_sourcecode/Ch01/Listing 1-23.cs new file mode 100644 index 0000000..1693dcc --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-23.cs @@ -0,0 +1,18 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Add(a: 10, b: 10); /* 20 */ +// Add(10, b: 10); /* 20 */ +// //Add(a: 10, 10); /* Compile time error, position */ +// } + +// static void Add(int a, int b) +// { +// Console.WriteLine(a + b); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-24.cs b/9781430248606_sourcecode/Ch01/Listing 1-24.cs new file mode 100644 index 0000000..3b3f8fd --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-24.cs @@ -0,0 +1,31 @@ +//using System; /* importing namespace */ + +//namespace Ch01 /* namespace declaration */ +//{ +// class Program /* class declaration*/ +// { +// static void Main(string[] args) /* method declaration */ +// { +// PowerGenerator pg = new PowerGenerator(); +// pg.ProcessPower(); +// } /* end of method declaration */ +// } /* end of class declaration */ + +// public class PowerGenerator +// { +// const int limit = 3; /* constant declaration */ +// const string +// original = "Original number", +// square = "Square number"; + +// public void ProcessPower() +// { +// Console.WriteLine("{0,16}{1,20}", +// original, square); /* statement*/ +// for (int i = 0; i <= limit; ++i) /* iteration statement*/ +// { +// Console.Write("{0,10}{1,20}\n", i, Math.Pow(i, 2)); +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-25.cs b/9781430248606_sourcecode/Ch01/Listing 1-25.cs new file mode 100644 index 0000000..2136e8c --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-25.cs @@ -0,0 +1,26 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int x, y; /* Declaration statement */ +// x = 10; /* Assignment expression */ +// y = 12; /* Assignment expression */ +// ++x; /* Increment expression */ +// --y; /* Decrement expression */ +// Show(x, y); /* Method call expression which will +// * show 22 as output*/ +// string message = +// new string('.', 10); /* object instantiation expression */ +// Console.WriteLine(message); /* Method call expression which will +// * show method */ +// } + +// static void Show(int a, int b) +// { +// Console.WriteLine(a + b); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-26.cs b/9781430248606_sourcecode/Ch01/Listing 1-26.cs new file mode 100644 index 0000000..ed6a04f --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-26.cs @@ -0,0 +1,15 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int a = 0; +// lock (a) +// { +// Console.WriteLine(a); +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-27.cs b/9781430248606_sourcecode/Ch01/Listing 1-27.cs new file mode 100644 index 0000000..36556b1 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-27.cs @@ -0,0 +1,17 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { + +// static void Main(string[] args) +// { +// AClass anObject = new AClass(); +// lock (anObject) +// { +// Console.WriteLine(anObject.ToString()); +// } +// } +// class AClass { } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-29.cs b/9781430248606_sourcecode/Ch01/Listing 1-29.cs new file mode 100644 index 0000000..6a810fb --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-29.cs @@ -0,0 +1,28 @@ +//using System; +//using System.IO; +//using System.Text; + +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// MethodB(); +// } + +// public static void MethodB() +// { +// using (MemoryStream ms = +// new MemoryStream(Encoding.ASCII.GetBytes("Expert C# 5.0"))) +// { +// int i = 0; +// do +// { +// int current = ms.ReadByte(); +// Console.Write("{0}\t{1}\n", current, (char)current); +// } while (++i < ms.Length); +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-3.cs b/9781430248606_sourcecode/Ch01/Listing 1-3.cs new file mode 100644 index 0000000..31bc156 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-3.cs @@ -0,0 +1,21 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int a = 100, @int = 100; /* int is keyword and @int used +// * as identifier */ +// try +// { /* try is keyword */ +// Console.Write(a / @int); +// } +// catch +// { +// throw; +// } /* catch and throw is keyword */ +// } + +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-30.cs b/9781430248606_sourcecode/Ch01/Listing 1-30.cs new file mode 100644 index 0000000..e1e966b --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-30.cs @@ -0,0 +1,26 @@ +//using System; +//using System.Collections; + +//namespace Ch01 +//{ +// class Program +// { +// static void Main() +// { +// foreach (int i in GeneratePower(2, 4)) +// { +// Console.Write("{0} ", i); +// } +// } + +// public static IEnumerable GeneratePower(int initialValue, int range) +// { +// int result = 1; +// for (int counter = 0; counter < range; ++counter) +// { +// result = result * initialValue; +// yield return result; +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-31.cs b/9781430248606_sourcecode/Ch01/Listing 1-31.cs new file mode 100644 index 0000000..903b6d5 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-31.cs @@ -0,0 +1,5 @@ +//namespace Ch01 +//{ +// class A { } +// class B { } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-32.cs b/9781430248606_sourcecode/Ch01/Listing 1-32.cs new file mode 100644 index 0000000..31d6e20 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-32.cs @@ -0,0 +1,4 @@ +//namespace Ch01Level3.Ch01Level2.Ch01Level1 +//{ +// class ClassA { } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-33.cs b/9781430248606_sourcecode/Ch01/Listing 1-33.cs new file mode 100644 index 0000000..0cf6db6 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-33.cs @@ -0,0 +1,10 @@ +//namespace Ch01Level3 +//{ +// namespace Ch01Level2 +// { +// namespace Ch01Level1 +// { +// class ClassA { } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-35.cs b/9781430248606_sourcecode/Ch01/Listing 1-35.cs new file mode 100644 index 0000000..b28d031 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-35.cs @@ -0,0 +1,8 @@ +//namespace Ch01 +//{ +// class ClassA { } +//} + +//namespace Ch01 +//{ +// class ClassB { } diff --git a/9781430248606_sourcecode/Ch01/Listing 1-37.cs b/9781430248606_sourcecode/Ch01/Listing 1-37.cs new file mode 100644 index 0000000..87d55f1 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-37.cs @@ -0,0 +1,12 @@ +//namespace Ch01.Using +//{ +// using Ch01; /* using statement imports the namespace +// * defined in the Listing 1-36 */ +// using One = Ch01; /* using alias directives One refers to +// * the Ch01 */ +// class ClassC +// { +// private ClassB classB; +// private One.ClassA classA; +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-38.cs b/9781430248606_sourcecode/Ch01/Listing 1-38.cs new file mode 100644 index 0000000..98ee39a --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-38.cs @@ -0,0 +1,29 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Person person = new Person() +// { +// Name = "Person A", +// Address = "Address of Person A" +// }; +// Console.WriteLine(person.ToString()); +// } +// } + +// public class Person +// { +// public override string ToString() +// { +// return string.Format("Name: {0}\nAddress:{1}", Name, Address); +// } + +// public string Name { get; set; } +// public string Address { get; set; } +// } +// public class Address { }; /* ; is optional and it used in here +// * to show the usage of it.*/ +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-39.cs b/9781430248606_sourcecode/Ch01/Listing 1-39.cs new file mode 100644 index 0000000..db28635 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-39.cs @@ -0,0 +1,13 @@ +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) {} +// protected internal void MethodA(){} /* Valid use of access modifiers +// * combination */ +// public internal void MethodA(){} /* Invalid use of access +// * modifiers combination */ +// private internal void MethodA(){} /* Invalid use of access +// * modifiers combination */ +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-4.cs b/9781430248606_sourcecode/Ch01/Listing 1-4.cs new file mode 100644 index 0000000..fe2beed --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-4.cs @@ -0,0 +1,17 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Book aBook = null; /* Reference type can be set with +// * null literal */ +// int chapters = null; /* Compiler error for value type +// * when set with null literal*/ +// Nullable pages = null; /* null can be set in value type +// * when it is a type of Nullable */ +// } +// } +// class Book { } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-40.cs b/9781430248606_sourcecode/Ch01/Listing 1-40.cs new file mode 100644 index 0000000..c7109ef --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-40.cs @@ -0,0 +1,24 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// StandardCalculator sc = new StandardCalculator(); +// Console.WriteLine(sc.Add(10, 10)); /* 20 */ +// Console.WriteLine(sc.Sub(10, 10)); /* 0 */ +// } +// } + +// public abstract class Calculator +// { +// public abstract int Add(int a, int b); +// public int Sub(int a, int b) { return b - a; } +// } + +// public class StandardCalculator : Calculator +// { +// public override int Add(int a, int b) { return a + b; } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-41.cs b/9781430248606_sourcecode/Ch01/Listing 1-41.cs new file mode 100644 index 0000000..f0c4b2f --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-41.cs @@ -0,0 +1,19 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Person person = new Person +// { +// Age = 30 +// }; +// } +// } + +// public sealed class Person +// { +// public int Age { get; set; } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-42.cs b/9781430248606_sourcecode/Ch01/Listing 1-42.cs new file mode 100644 index 0000000..88d9f40 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-42.cs @@ -0,0 +1,17 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Console.WriteLine("{0}", Calculator.Add(10, 10)); +// } +// } + +// public static class Calculator /* A static class declaration */ +// { +// /* A static method declaration */ +// public static int Add(int a, int b) { return a + b; } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-43.cs b/9781430248606_sourcecode/Ch01/Listing 1-43.cs new file mode 100644 index 0000000..98c3981 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-43.cs @@ -0,0 +1,18 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Person person = new Person(); +// } +// } + +// public class Person +// { +// /* Empty class, there hasn't been declared any explicit constructor, +// * property or method. After compiling C# compiler will add a +// * default constructor*/ +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-44.cs b/9781430248606_sourcecode/Ch01/Listing 1-44.cs new file mode 100644 index 0000000..cfb8715 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-44.cs @@ -0,0 +1,23 @@ +//using System; + +//namespace Ch01 +//{ +// class Program +// { +// public static int Y = StaticClass.X + 1; /* StaticClass.X= 1 */ +// static Program() { } +// static void Main() +// { +// Console.WriteLine("X = {0}, Y = {1}", StaticClass.X, Program.Y); +// } +// } + +// class StaticClass +// { +// public static int X; /*0*/ +// static StaticClass() +// { +// X = Program.Y + 1; /* Program.Y = 0 */ +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-45.cs b/9781430248606_sourcecode/Ch01/Listing 1-45.cs new file mode 100644 index 0000000..a4ecee3 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-45.cs @@ -0,0 +1,23 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// /* A static method */ +// static void Main(string[] args) +// { +// AClass anInstanceOfAClass = new AClass(); +// anInstanceOfAClass.Display(); +// } +// } + +// public class AClass +// { +// /* An instance method */ +// public void Display() +// { +// Console.WriteLine("Hello world! from the Main method"); +// /* Hello world! from the Main method */ +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-46.cs b/9781430248606_sourcecode/Ch01/Listing 1-46.cs new file mode 100644 index 0000000..7c76654 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-46.cs @@ -0,0 +1,27 @@ +//using System; + +//namespace Ch01 +//{ +// class Program +// { +// static void Main() +// { +// AClass.Method1(); /* Call Method1 but Method2 is not +// * accessible outside of the AClass*/ +// Console.ReadLine(); + +// } +// } +// public static class AClass +// { +// public static void Method1() +// { +// Console.WriteLine("Method 1"); +// Method2(); +// } +// private static void Method2() +// { +// Console.WriteLine("Method 2"); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-47.cs b/9781430248606_sourcecode/Ch01/Listing 1-47.cs new file mode 100644 index 0000000..4132af2 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-47.cs @@ -0,0 +1,31 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main() +// { +// AClass anObjectOfAClass = new AClass(); +// anObjectOfAClass.Method1(); +// Console.ReadLine(); +// } +// } +// public class AClass +// { +// public void Method1() +// { +// Console.WriteLine("Method 1"); +// this.Method2(); /* this keyword used to invoke methodd2 */ +// } +// private void Method2() +// { +// Console.WriteLine("Method 2"); +// Method3(); /* this keyword can not be used to +// * static methodd3 */ +// } +// public static void Method3() +// { +// Console.WriteLine("Method 2"); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-48.cs b/9781430248606_sourcecode/Ch01/Listing 1-48.cs new file mode 100644 index 0000000..1a78d66 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-48.cs @@ -0,0 +1,29 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main() +// { +// D anObjectOfDClass = new D(); +// anObjectOfDClass.Method1(); +// Console.ReadLine(); +// } +// } + +// public class B +// { +// public virtual void Method1() +// { +// Console.WriteLine(ToString()); +// } +// } + +// public class D : B +// { +// public override void Method1() /* virtual method overriden */ +// { +// Console.WriteLine(ToString()); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-49.cs b/9781430248606_sourcecode/Ch01/Listing 1-49.cs new file mode 100644 index 0000000..920bb55 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-49.cs @@ -0,0 +1,26 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main() +// { +// AClass anObjectOfAClass = new AClass(); +// anObjectOfAClass.Method1(); +// Console.ReadLine(); + +// } +// } +// public class AClass : BaseClass +// { +// public override void Method1() +// { +// Console.WriteLine(ToString()); +// } +// } + +// public abstract class BaseClass +// { +// public abstract void Method1(); +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-5.cs b/9781430248606_sourcecode/Ch01/Listing 1-5.cs new file mode 100644 index 0000000..1c7c356 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-5.cs @@ -0,0 +1,16 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int a = 10; /* int type */ +// Book book = new Book(); /* struct type */ +// Planets planets = Planets.Earth; /* enum type */ +// } +// } + +// struct Book { } /* struct type declaration */ +// enum Planets { Earth = 0 } /* enum type declaration*/ +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-50.cs b/9781430248606_sourcecode/Ch01/Listing 1-50.cs new file mode 100644 index 0000000..e2d22db --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-50.cs @@ -0,0 +1,35 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main() +// { +// AClass anObjectOfAClass = new AClass(); +// anObjectOfAClass.Method1(); +// anObjectOfAClass.Method2(); + +// BClass anObjectOfBClass = new BClass(); +// anObjectOfBClass.Method1(); +// Console.ReadLine(); +// } +// } + +// public class BaseClass +// { +// public virtual void Method1() { Console.WriteLine(ToString()); } +// public virtual void Method2() { Console.WriteLine(ToString()); } +// } + +// public class AClass : BaseClass +// { +// public override void Method1() { Console.WriteLine(ToString()); } +// public sealed override void Method2() +// { Console.WriteLine(ToString()); } +// } + +// public class BClass : AClass +// { +// public override void Method1() { Console.WriteLine("Overriden"); } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-51.cs b/9781430248606_sourcecode/Ch01/Listing 1-51.cs new file mode 100644 index 0000000..620e914 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-51.cs @@ -0,0 +1,20 @@ +//using System; +//using System.Runtime.InteropServices; +//namespace Ch01 +//{ +// class Program +// { +// [DllImport("User32.dll")] +// static extern Boolean MessageBeep(UInt32 beepType); + +// static void Main() +// { +// MessageBeep((UInt32)BeepTypes.MB_ICONEXCLAMATION); +// } +// enum BeepTypes +// { +// MB_ICONASTERISK = 0x00000040, +// MB_ICONEXCLAMATION = 0x00000030 +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-52.cs b/9781430248606_sourcecode/Ch01/Listing 1-52.cs new file mode 100644 index 0000000..6a050a4 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-52.cs @@ -0,0 +1,36 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main() +// { +// AClass anObjectOfAClass = new AClass(); +// anObjectOfAClass.Method1(); +// anObjectOfAClass.Method2(); +// Console.ReadLine(); +// } +// } + +// public abstract class BaseClass { public abstract void Method1();} + +// public class BaseClass2 : BaseClass +// { +// public override void Method1() +// { +// Console.WriteLine( +// "Method1 of the BaseClass overridden in the BaseClass2"); +// } + +// public virtual void Method2() +// { Console.WriteLine("Method2 define as virtual in the BaseClass2"); } + +// } +// public class AClass : BaseClass2 +// { +// public override void Method1() +// { Console.WriteLine("Method1 of the AClass overridden"); } +// public override void Method2() +// { Console.WriteLine("Method2 of the AClass overridden"); } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-53.cs b/9781430248606_sourcecode/Ch01/Listing 1-53.cs new file mode 100644 index 0000000..cb066d7 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-53.cs @@ -0,0 +1,23 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main() +// { +// A anObject = new A(); +// } +// } + +// public partial class A +// { +// public A() { MethodOfA("Partial method"); } +// partial void MethodOfA(string s); +// } + +// /* This part can be in a separate file. */ +// public partial class A +// { +// partial void MethodOfA(String s) { Console.WriteLine("{0}", s); } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-54.cs b/9781430248606_sourcecode/Ch01/Listing 1-54.cs new file mode 100644 index 0000000..c6d2c30 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-54.cs @@ -0,0 +1,35 @@ +//using System; +//namespace Ch01 +//{ +// public delegate void EventHandler(string name); + +// class Program +// { +// static void Main(string[] args) +// { +// Planets planets = new Planets(); +// for (int i = 0; i <= 8; ++i) +// Console.Write("{0}\t", planets[i]); +// Console.ReadLine(); +// } +// } + +// public class Planets +// { +// private string[] nameOfThePlanets = +// { "Sun", "Mercury", "Venus", "Earth", "Mars", "Jupiter", +// "Saturn", "Uranus", "Neptune" }; + +// public string this[int index] +// { +// get +// { +// return nameOfThePlanets[index]; +// } +// set +// { +// nameOfThePlanets[index] = value; +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-55.cs b/9781430248606_sourcecode/Ch01/Listing 1-55.cs new file mode 100644 index 0000000..455d463 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-55.cs @@ -0,0 +1,22 @@ +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Book aBook = new Book +// { +// Name = "Expert C# 5.0: with the .NET 4.5 Framework" +// }; +// } +// } +// public class Book +// { +// public Book() +// { Name = default(string); } + +// public string Name + +// { get; set; } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-56.cs b/9781430248606_sourcecode/Ch01/Listing 1-56.cs new file mode 100644 index 0000000..9e74319 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-56.cs @@ -0,0 +1,20 @@ +//public struct Point +//{ +// public const int ZeroPoint = 0; /* Constant declaration */ +// public int X; /* Field declaration */ +// public int Y; /* Field declaration */ +// private int length; +// public Point(int x, int y) /* Non-parameterless constructor */ +// { +// X = x; Y = y; +// length = X + Y; +// } +// public string ToString() /* Method declaration */ +// { +// return "X" + X + "\n Y:" + Y; +// } +// public int PointLength /* Read only Property declaration */ +// { +// get { return length; } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-57.cs b/9781430248606_sourcecode/Ch01/Listing 1-57.cs new file mode 100644 index 0000000..43ec381 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-57.cs @@ -0,0 +1,59 @@ +//using System; + +//namespace Ch01 +//{ +// public delegate void EventHandler(string name); +// class Program +// { +// static void Main(string[] args) +// { +// Book book = new Book(); +// book.ShowBookName += new EventHandler(book_ShowBookName); +// book.Name = "Expert C# 5.0 with .NET Framework 4.5"; +// Console.WriteLine(book.Name); +// } + +// static void book_ShowBookName(string name) +// { +// Console.WriteLine(name); +// } +// } + +// public class Book +// { +// public event EventHandler ShowBookName; +// private string name; + +// public string Name +// { +// set +// { +// BookEventArgs eventArgs = new BookEventArgs() +// { +// BookName = "Book name updated...." +// }; +// name = value; +// OnNameChanged(eventArgs); +// } +// get +// { +// return name; +// } + +// } + +// protected virtual void OnNameChanged(BookEventArgs args) +// { +// EventHandler handler = ShowBookName; +// if (handler != null) +// { +// handler(args.BookName); +// } +// } +// } +// public class BookEventArgs : EventArgs +// { +// public string BookName { get; set; } +// } + +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-58.cs b/9781430248606_sourcecode/Ch01/Listing 1-58.cs new file mode 100644 index 0000000..df6ee7f --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-58.cs @@ -0,0 +1,43 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Calculator calculator = new Calculator(); +// Console.WriteLine(calculator.Add(10, 10)); /* 20 */ +// Console.WriteLine(calculator.Sub(10, 10)); /* 0 */ +// Console.WriteLine(calculator.Mul(9, 7)); /* 63 */ +// } +// } + +// /* interface definition*/ +// interface IAddition { int Add(int a, int b);} /* Interface declaration */ +// interface IExAddition { int Add(int a, int b);} /* Interface declaration */ +// interface ISubtraction { int Sub(int a, int b);}/* Interface declaration */ +// interface IMultiplication : IAddition { int Mul(int a, int b); } /* Extending Interface declaration */ + +// /* interface implementation*/ +// public class Calculator : +// IAddition, +// ISubtraction, +// IMultiplication, +// IExAddition /* Multiple interface implementation */ +// { +// public int Add(int a, int b) { return a + b; } + +// int IExAddition.Add(int a, int b) /* Explicit interface implementation */ +// { return 100 + a + b; } + +// public int Sub(int a, int b) { return a > b ? a - b : b - a; } + +// public int Mul(int a, int b) +// { +// var result = 0; +// for (int i = 0; i < a; ++i) +// result += Add(0, b); +// return result; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-59.cs b/9781430248606_sourcecode/Ch01/Listing 1-59.cs new file mode 100644 index 0000000..c7b6914 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-59.cs @@ -0,0 +1,26 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Calculator calculator = new ScientificCalculator(); +// Console.WriteLine(calculator.Add(10, 10)); /* 120 */ +// } +// } + +// /* Interface declaration */ +// interface IAddition { int Add(int a, int b); } + +// /* Interface implementation */ +// public class Calculator : IAddition +// { +// public virtual int Add(int a, int b) { return a + b; } +// } + +// public class ScientificCalculator : Calculator +// { +// public override int Add(int a, int b) { return 100 + a + b; } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-6.cs b/9781430248606_sourcecode/Ch01/Listing 1-6.cs new file mode 100644 index 0000000..64f906a --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-6.cs @@ -0,0 +1,15 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IBook book = new Book(); /* book is an instance of the Book */ +// } +// } + +// interface IBook { } + +// class Book : IBook { } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-60.cs b/9781430248606_sourcecode/Ch01/Listing 1-60.cs new file mode 100644 index 0000000..9e35932 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-60.cs @@ -0,0 +1,40 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// public enum Planets +// { +// Sun, +// Mercury, +// Venus, +// Earth, +// Mars, +// Jupiter, +// Saturn, +// Uranus, +// Neptune +// } +// static void Main() +// { +// DisplayInformation(Planets.Earth); +// DisplayInformation(Planets.Mars); +// DisplayInformation(Planets.Jupiter); +// } +// static void DisplayInformation(Planets planets) +// { +// switch (planets) +// { +// case Planets.Earth: +// Console.WriteLine("Third planet from the Sun"); +// break; +// case Planets.Mars: +// Console.WriteLine("The fourth planet from the Sun"); +// break; +// default: +// Console.WriteLine("Please provide valid Planet name"); +// break; +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-61.cs b/9781430248606_sourcecode/Ch01/Listing 1-61.cs new file mode 100644 index 0000000..197a7ad --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-61.cs @@ -0,0 +1,33 @@ +//using System; +//namespace Ch01 +//{ +// /* A delegate which will encapsulate a method which accept two parameter +// * and return int */ +// delegate int BinaryOperation(int x, int y); + +// class Program +// { +// static void Main(string[] args) +// { +// Calculate(Add, new Tuple(10, 10)); /* 20 */ +// Calculate(Sub, new Tuple(10, 10)); /* 0 */ +// Calculate(Sub, new Tuple(1, 10)); /* 9 */ +// } + +// static void Calculate( +// BinaryOperation binaryOperation, Tuple data) +// { +// Console.WriteLine(binaryOperation(data.Item1, data.Item2)); +// } + +// static int Add(int x, int y) +// { +// return x + y; +// } + +// static int Sub(int x, int y) +// { +// return x > y ? x - y : y - x; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-62.cs b/9781430248606_sourcecode/Ch01/Listing 1-62.cs new file mode 100644 index 0000000..f5463cd --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-62.cs @@ -0,0 +1,22 @@ +//using System; + +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int a = 10, b = 0; +// Division div = new Division(); +// Console.WriteLine("{0}/{1}={2}", a, b, div.Divide(a, b)); +// } + +// public class Division +// { +// public int Divide(int a, int b) +// { +// return a / b; +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-7.cs b/9781430248606_sourcecode/Ch01/Listing 1-7.cs new file mode 100644 index 0000000..77c2a9d --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-7.cs @@ -0,0 +1,19 @@ +//using System; +//namespace Ch01 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// AClass aClass = new AClass(); +// Console.WriteLine(aClass.MethodA(10)); +// Console.ReadLine(); +// } +// } + +// public class AClass +// { +// public int MethodA(int a) { return a * MethodB(); } +// public int MethodB() { return 10; } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-8.cs b/9781430248606_sourcecode/Ch01/Listing 1-8.cs new file mode 100644 index 0000000..4c39faa --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-8.cs @@ -0,0 +1,16 @@ +//using System; +//using System.Collections; + +//namespace Ch01 +//{ +// class MainClass +// { +// static void Main(string[] args) +// { +// ArrayList al = new ArrayList(); +// al.Add("C#"); +// Console.WriteLine(al.Count); /* 1 */ +// Console.WriteLine(al[0]); /* C# */ +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Listing 1-9.cs b/9781430248606_sourcecode/Ch01/Listing 1-9.cs new file mode 100644 index 0000000..ca5c8d5 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Listing 1-9.cs @@ -0,0 +1,18 @@ +//using System; +//using System.Collections; + +//namespace Ch01 +//{ +// class MainClass +// { +// static void Main(string[] args) +// { +// Hashtable htArray = new Hashtable(); +// htArray["1"] = "Milky way"; +// htArray["2"] = "Galaxy"; +// Console.WriteLine(htArray.Count); /* 2 */ +// Console.WriteLine(htArray["1"]); /* Milky way */ +// Console.WriteLine(htArray["2"]); /* Galaxy */ +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch01/Program.cs b/9781430248606_sourcecode/Ch01/Program.cs new file mode 100644 index 0000000..f89678d --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Program.cs @@ -0,0 +1,31 @@ +using System; /* importing namespace */ + +namespace Ch01 /* namespace declaration */ +{ + class Program /* class declaration*/ + { + static void Main(string[] args) /* method declaration */ + { + PowerGenerator pg = new PowerGenerator(); + pg.ProcessPower(); + } /* end of method declaration */ + } /* end of class declaration */ + + public class PowerGenerator + { + const int limit = 3; /* constant declaration */ + const string + original = "Original number", + square = "Square number"; + + public void ProcessPower() + { + Console.WriteLine("{0,16}{1,20}", + original, square); /* statement*/ + for (int i = 0; i <= limit; ++i) /* iteration statement*/ + { + Console.Write("{0,10}{1,20}\n", i, Math.Pow(i, 2)); + } + } + } +} /* end of namespace declaration */ diff --git a/9781430248606_sourcecode/Ch01/Properties/AssemblyInfo.cs b/9781430248606_sourcecode/Ch01/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b12673f --- /dev/null +++ b/9781430248606_sourcecode/Ch01/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ch01")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ch01")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c5135208-bec0-4422-bf8a-493c3e2d39a1")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9781430248606_sourcecode/Ch01/app.config b/9781430248606_sourcecode/Ch01/app.config new file mode 100644 index 0000000..c5e1dae --- /dev/null +++ b/9781430248606_sourcecode/Ch01/app.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch01/bin/Release/Ch01.exe b/9781430248606_sourcecode/Ch01/bin/Release/Ch01.exe new file mode 100644 index 0000000..8939db4 Binary files /dev/null and b/9781430248606_sourcecode/Ch01/bin/Release/Ch01.exe differ diff --git a/9781430248606_sourcecode/Ch01/bin/Release/Ch01.exe.config b/9781430248606_sourcecode/Ch01/bin/Release/Ch01.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/bin/Release/Ch01.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch01/bin/Release/Ch01.pdb b/9781430248606_sourcecode/Ch01/bin/Release/Ch01.pdb new file mode 100644 index 0000000..d83728f Binary files /dev/null and b/9781430248606_sourcecode/Ch01/bin/Release/Ch01.pdb differ diff --git a/9781430248606_sourcecode/Ch01/obj/x86/Debug/Ch01.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch01/obj/x86/Debug/Ch01.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..14e4f68 --- /dev/null +++ b/9781430248606_sourcecode/Ch01/obj/x86/Debug/Ch01.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch01\bin\Debug\Ch01.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch01\bin\Debug\Ch01.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch01\bin\Debug\Ch01.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch01\obj\x86\Debug\Ch01.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch01\obj\x86\Debug\Ch01.pdb diff --git a/9781430248606_sourcecode/Ch01/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch01/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..793a1ac Binary files /dev/null and b/9781430248606_sourcecode/Ch01/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch01/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/9781430248606_sourcecode/Ch01/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch01/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/9781430248606_sourcecode/Ch01/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch01/obj/x86/Release/Ch01.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch01/obj/x86/Release/Ch01.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..bec02ac --- /dev/null +++ b/9781430248606_sourcecode/Ch01/obj/x86/Release/Ch01.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch01\bin\Release\Ch01.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch01\bin\Release\Ch01.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch01\bin\Release\Ch01.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch01\obj\x86\Release\ResolveAssemblyReference.cache +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch01\obj\x86\Release\Ch01.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch01\obj\x86\Release\Ch01.pdb diff --git a/9781430248606_sourcecode/Ch01/obj/x86/Release/Ch01.exe b/9781430248606_sourcecode/Ch01/obj/x86/Release/Ch01.exe new file mode 100644 index 0000000..8939db4 Binary files /dev/null and b/9781430248606_sourcecode/Ch01/obj/x86/Release/Ch01.exe differ diff --git a/9781430248606_sourcecode/Ch01/obj/x86/Release/Ch01.pdb b/9781430248606_sourcecode/Ch01/obj/x86/Release/Ch01.pdb new file mode 100644 index 0000000..d83728f Binary files /dev/null and b/9781430248606_sourcecode/Ch01/obj/x86/Release/Ch01.pdb differ diff --git a/9781430248606_sourcecode/Ch01/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch01/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..5ab1f9c Binary files /dev/null and b/9781430248606_sourcecode/Ch01/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch02/Ch02.csproj b/9781430248606_sourcecode/Ch02/Ch02.csproj new file mode 100644 index 0000000..4651fe8 --- /dev/null +++ b/9781430248606_sourcecode/Ch02/Ch02.csproj @@ -0,0 +1,72 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {BA648C1E-279B-4198-B305-2DF1C043CFA2} + Exe + Properties + Ch02 + Ch02 + v4.5 + + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch02/Listing 2-1.cs b/9781430248606_sourcecode/Ch02/Listing 2-1.cs new file mode 100644 index 0000000..7b4eeed --- /dev/null +++ b/9781430248606_sourcecode/Ch02/Listing 2-1.cs @@ -0,0 +1,19 @@ +//using System; + +//namespace Ch02 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Person aPerson = new Person() +// { +// Name = "A" +// }; +// } +// } +// public class Person +// { +// public string Name { get; set; } +// } +//} diff --git a/9781430248606_sourcecode/Ch02/Listing 2-11.cs b/9781430248606_sourcecode/Ch02/Listing 2-11.cs new file mode 100644 index 0000000..e618296 --- /dev/null +++ b/9781430248606_sourcecode/Ch02/Listing 2-11.cs @@ -0,0 +1,15 @@ +//using System; +//using System.Collections.Generic; +//namespace Ch02 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList ll = new List(); +// for (int i = 0; i <= Int16.MaxValue * 2; ++i) +// ll.Add(i); +// foreach (int st in ll) ; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch02/Listing 2-12.cs b/9781430248606_sourcecode/Ch02/Listing 2-12.cs new file mode 100644 index 0000000..a21bf85 --- /dev/null +++ b/9781430248606_sourcecode/Ch02/Listing 2-12.cs @@ -0,0 +1,16 @@ +//using System; +//using System.Collections; + +//namespace Ch02 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// ArrayList ll = new ArrayList(); +// for (int i = 0; i <= Int16.MaxValue * 2; ++i) +// ll.Add(i); +// foreach (int st in ll) ; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch02/Listing 2-2.cs b/9781430248606_sourcecode/Ch02/Listing 2-2.cs new file mode 100644 index 0000000..12fa29a --- /dev/null +++ b/9781430248606_sourcecode/Ch02/Listing 2-2.cs @@ -0,0 +1,19 @@ +//namespace Ch02 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// TestClass testClass = new TestClass(); +// testClass.TestMethod(10); +// } +// } + +// public class TestClass +// { +// public int TestMethod(int a) +// { +// return a + a; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch02/Listing 2-3.cs b/9781430248606_sourcecode/Ch02/Listing 2-3.cs new file mode 100644 index 0000000..bbdd7df --- /dev/null +++ b/9781430248606_sourcecode/Ch02/Listing 2-3.cs @@ -0,0 +1,22 @@ +//namespace Ch02 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Math fc = new Math(); +// var result = fc.Factorial(3); +// } +// } + +// public class Math +// { +// public int Factorial(int a) +// { +// if (a <= 1) +// return a; +// else +// return a * Factorial(a - 1); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch02/Listing 2-4.cs b/9781430248606_sourcecode/Ch02/Listing 2-4.cs new file mode 100644 index 0000000..4f4b627 --- /dev/null +++ b/9781430248606_sourcecode/Ch02/Listing 2-4.cs @@ -0,0 +1,14 @@ +//namespace Ch02 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// TestClass testClass = new TestClass(); +// } +// } + +// public class TestClass +// { +// } +//} diff --git a/9781430248606_sourcecode/Ch02/Listing 2-5.cs b/9781430248606_sourcecode/Ch02/Listing 2-5.cs new file mode 100644 index 0000000..95401c6 --- /dev/null +++ b/9781430248606_sourcecode/Ch02/Listing 2-5.cs @@ -0,0 +1,25 @@ +//using System; + +//namespace Ch02 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// byte aByte = 1; +// int aInt = 10; +// float aFloat = 10.5f; +// long aLong = 10; +// bool aBool = true; +// char aChar = 'C'; +// IntPtr aIntPtr = IntPtr.Zero; +// string aString = "string literal"; + +// ReferenceType referenceType = new ReferenceType(); + +// Console.WriteLine("Finish the execution"); +// } +// } + +// public class ReferenceType { } +//} diff --git a/9781430248606_sourcecode/Ch02/Listing 2-6.cs b/9781430248606_sourcecode/Ch02/Listing 2-6.cs new file mode 100644 index 0000000..f5817ab --- /dev/null +++ b/9781430248606_sourcecode/Ch02/Listing 2-6.cs @@ -0,0 +1,33 @@ +//namespace Ch02 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int aInt = 2012; +// TestClass aTestClass = new TestClass(); +// AInterface aInterfaceImplementation = new InterfaceImplementation(); +// AStruct aAStruct = new AStruct(); +// } +// } + +// public class TestClass +// { +// public void TestMethod() {/*Code removed*/} +// } + +// public interface AInterface +// { +// void AMethod(); +// } + +// public class InterfaceImplementation : AInterface +// { +// public void AMethod() {/*Code removed*/} +// } + +// public struct AStruct +// { +// public int ANumber { get; set; } +// } +//} diff --git a/9781430248606_sourcecode/Ch02/Listing 2-8.cs b/9781430248606_sourcecode/Ch02/Listing 2-8.cs new file mode 100644 index 0000000..55c9431 --- /dev/null +++ b/9781430248606_sourcecode/Ch02/Listing 2-8.cs @@ -0,0 +1,36 @@ +//using System; + +//namespace Ch02 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int aInt = 2012; +// string aStringLiteral = "Expert C# 5.0: with the .NET 4.5 Framework"; +// TestClass testClass = new TestClass(); + +// Console.WriteLine("{0} {1}.", +// testClass.CastingString(aStringLiteral), +// testClass.BoxInt(aInt)); +// } +// } + +// public class TestClass +// { + +// public int BoxInt(object aInt) +// { +// int unboxedInt = 0; +// unboxedInt = (int)aInt; +// return unboxedInt; +// } + +// public string CastingString(object aStringLieteral) +// { +// string unboxedString = string.Empty; +// unboxedString = (string)aStringLieteral; +// return unboxedString; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch02/Program.cs b/9781430248606_sourcecode/Ch02/Program.cs new file mode 100644 index 0000000..2d9df81 --- /dev/null +++ b/9781430248606_sourcecode/Ch02/Program.cs @@ -0,0 +1,21 @@ +using System; + +namespace Ch02 +{ + class Program + { + static void Main(string[] args) + { + Person aPerson = new Person() + { + Name = "A" + }; + } + } + public class Person + { + public string Name { get; set; } + } +} + + diff --git a/9781430248606_sourcecode/Ch02/Properties/AssemblyInfo.cs b/9781430248606_sourcecode/Ch02/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a08e5b5 --- /dev/null +++ b/9781430248606_sourcecode/Ch02/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ch02")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ch02")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3f17f6f1-423c-4bcf-ab80-d8449a6e40f3")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9781430248606_sourcecode/Ch02/app.config b/9781430248606_sourcecode/Ch02/app.config new file mode 100644 index 0000000..c5e1dae --- /dev/null +++ b/9781430248606_sourcecode/Ch02/app.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch02/bin/Debug/Ch02.vshost.exe b/9781430248606_sourcecode/Ch02/bin/Debug/Ch02.vshost.exe new file mode 100644 index 0000000..bb84a51 Binary files /dev/null and b/9781430248606_sourcecode/Ch02/bin/Debug/Ch02.vshost.exe differ diff --git a/9781430248606_sourcecode/Ch02/bin/Debug/Ch02.vshost.exe.config b/9781430248606_sourcecode/Ch02/bin/Debug/Ch02.vshost.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch02/bin/Debug/Ch02.vshost.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch02/bin/Release/Ch02.exe b/9781430248606_sourcecode/Ch02/bin/Release/Ch02.exe new file mode 100644 index 0000000..3689699 Binary files /dev/null and b/9781430248606_sourcecode/Ch02/bin/Release/Ch02.exe differ diff --git a/9781430248606_sourcecode/Ch02/bin/Release/Ch02.exe.config b/9781430248606_sourcecode/Ch02/bin/Release/Ch02.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch02/bin/Release/Ch02.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch02/bin/Release/Ch02.pdb b/9781430248606_sourcecode/Ch02/bin/Release/Ch02.pdb new file mode 100644 index 0000000..e85980d Binary files /dev/null and b/9781430248606_sourcecode/Ch02/bin/Release/Ch02.pdb differ diff --git a/9781430248606_sourcecode/Ch02/bin/Release/Ch02.vshost.exe b/9781430248606_sourcecode/Ch02/bin/Release/Ch02.vshost.exe new file mode 100644 index 0000000..bb84a51 Binary files /dev/null and b/9781430248606_sourcecode/Ch02/bin/Release/Ch02.vshost.exe differ diff --git a/9781430248606_sourcecode/Ch02/bin/Release/Ch02.vshost.exe.config b/9781430248606_sourcecode/Ch02/bin/Release/Ch02.vshost.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch02/bin/Release/Ch02.vshost.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch02/bin/Release/Ch02.vshost.exe.manifest b/9781430248606_sourcecode/Ch02/bin/Release/Ch02.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/9781430248606_sourcecode/Ch02/bin/Release/Ch02.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/9781430248606_sourcecode/Ch02/obj/x86/Debug/Ch02.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch02/obj/x86/Debug/Ch02.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..3012858 --- /dev/null +++ b/9781430248606_sourcecode/Ch02/obj/x86/Debug/Ch02.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch02\bin\Debug\Ch02.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch02\bin\Debug\Ch02.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch02\bin\Debug\Ch02.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch02\obj\x86\Debug\Ch02.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch02\obj\x86\Debug\Ch02.pdb diff --git a/9781430248606_sourcecode/Ch02/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch02/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..d501e0c Binary files /dev/null and b/9781430248606_sourcecode/Ch02/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch02/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/9781430248606_sourcecode/Ch02/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch02/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/9781430248606_sourcecode/Ch02/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch02/obj/x86/Release/Ch02.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch02/obj/x86/Release/Ch02.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..fbc37d0 --- /dev/null +++ b/9781430248606_sourcecode/Ch02/obj/x86/Release/Ch02.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch02\bin\Release\Ch02.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch02\bin\Release\Ch02.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch02\bin\Release\Ch02.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch02\obj\x86\Release\ResolveAssemblyReference.cache +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch02\obj\x86\Release\Ch02.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch02\obj\x86\Release\Ch02.pdb diff --git a/9781430248606_sourcecode/Ch02/obj/x86/Release/Ch02.exe b/9781430248606_sourcecode/Ch02/obj/x86/Release/Ch02.exe new file mode 100644 index 0000000..3689699 Binary files /dev/null and b/9781430248606_sourcecode/Ch02/obj/x86/Release/Ch02.exe differ diff --git a/9781430248606_sourcecode/Ch02/obj/x86/Release/Ch02.pdb b/9781430248606_sourcecode/Ch02/obj/x86/Release/Ch02.pdb new file mode 100644 index 0000000..e85980d Binary files /dev/null and b/9781430248606_sourcecode/Ch02/obj/x86/Release/Ch02.pdb differ diff --git a/9781430248606_sourcecode/Ch02/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch02/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..e9a99a4 Binary files /dev/null and b/9781430248606_sourcecode/Ch02/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch03/Ch03.csproj b/9781430248606_sourcecode/Ch03/Ch03.csproj new file mode 100644 index 0000000..353fcd4 --- /dev/null +++ b/9781430248606_sourcecode/Ch03/Ch03.csproj @@ -0,0 +1,72 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {490B178E-CAD9-49D9-8B0F-AD699E18FFBF} + Exe + Properties + Ch03 + Ch03 + v4.5 + + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch03/Listing 3-1.cs b/9781430248606_sourcecode/Ch03/Listing 3-1.cs new file mode 100644 index 0000000..8c87941 --- /dev/null +++ b/9781430248606_sourcecode/Ch03/Listing 3-1.cs @@ -0,0 +1,29 @@ +//using System; + +//namespace Ch03 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// BuiltInValuePassingAsValue temp = new BuiltInValuePassingAsValue(); +// temp.MethodA(); +// } +// } + +// public class BuiltInValuePassingAsValue +// { +// public BuiltInValuePassingAsValue() +// { Console.WriteLine("Built in value type passing as value"); } + +// public void MethodA() +// { +// int a = 10, b = 10; +// MethodB(a, b); +// Console.WriteLine("Method A: {0},{1}", a, b); +// } + +// public void MethodB(int a, int b) +// { Console.WriteLine("Method B: {0},{1}", a, b); } +// } +//} diff --git a/9781430248606_sourcecode/Ch03/Listing 3-12.cs b/9781430248606_sourcecode/Ch03/Listing 3-12.cs new file mode 100644 index 0000000..1bfcd9d --- /dev/null +++ b/9781430248606_sourcecode/Ch03/Listing 3-12.cs @@ -0,0 +1,47 @@ +//using System; + +//namespace Ch03 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// ObjectAsValue temp = new ObjectAsValue(); +// temp.MethodA(); +// } +// } + +// public class ObjectAsValue +// { +// public ObjectAsValue() +// { +// Console.WriteLine("Object as value"); +// } + +// public void MethodA() +// { +// Person aPerson = new Person() +// { +// Name = "APerson" +// }; +// MethodB(ref aPerson); +// Console.WriteLine("Method A: {0}", aPerson.Name); +// } + +// public void MethodB(ref Person aPerson) +// { +// Console.WriteLine("Method B: {0}", aPerson.Name); +// aPerson = new Person() +// { +// Name = "New name" +// }; +// } +// } + +// public class Person +// { +// public string Name +// { get; set; } +// } + +//} diff --git a/9781430248606_sourcecode/Ch03/Listing 3-15.cs b/9781430248606_sourcecode/Ch03/Listing 3-15.cs new file mode 100644 index 0000000..4e111a8 --- /dev/null +++ b/9781430248606_sourcecode/Ch03/Listing 3-15.cs @@ -0,0 +1,16 @@ +//using System; +//namespace Ch03 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int result = GetTotalPrice(); /* Test scenario 1- with the value */ +// result = GetTotalPrice(55); /* Test scenario 2 - with the value*/ +// } +// public static int GetTotalPrice(int basePrice = 40) +// { +// return basePrice - (basePrice * 10) / 100; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch03/Listing 3-17.cs b/9781430248606_sourcecode/Ch03/Listing 3-17.cs new file mode 100644 index 0000000..dd335f2 --- /dev/null +++ b/9781430248606_sourcecode/Ch03/Listing 3-17.cs @@ -0,0 +1,15 @@ +//using System; + +//namespace Ch03 +//{ +// class Program +// { +// static void Main(string[] args) { } + +// /* The C# compiler complain in here as reference type Person used for the default value.*/ +// public static string GetPersonDetails(Person aPerson = new Person()) +// { return aPerson.ToString(); } +// } + +// public class Person { } +//} diff --git a/9781430248606_sourcecode/Ch03/Listing 3-18.cs b/9781430248606_sourcecode/Ch03/Listing 3-18.cs new file mode 100644 index 0000000..3c4b58d --- /dev/null +++ b/9781430248606_sourcecode/Ch03/Listing 3-18.cs @@ -0,0 +1,21 @@ +//using System; + +//namespace Ch03 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// GetNameWithDefaultValue(); +// GetNameWithDefaultValue("Expert C# 5.0 by Mohammad Rahman", "C#"); +// } + +// /* Default value has been set as of string type */ +// public static void GetNameWithDefaultValue( +// string name = "Expert C# 5.0: with the .NET 4.5 Framework", +// string language = ": C#") +// { +// Console.WriteLine("{0} {1}", name, language); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch03/Listing 3-4.cs b/9781430248606_sourcecode/Ch03/Listing 3-4.cs new file mode 100644 index 0000000..d63a139 --- /dev/null +++ b/9781430248606_sourcecode/Ch03/Listing 3-4.cs @@ -0,0 +1,34 @@ +//using System; + +//namespace Ch03 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// BuiltInValuePassingAsRef temp = new BuiltInValuePassingAsRef(); +// temp.MethodA(); +// } +// } + +// public class BuiltInValuePassingAsRef +// { +// public BuiltInValuePassingAsRef() +// { +// Console.WriteLine("Built in value type passing as ref"); +// } + +// public void MethodA() +// { +// int a = 10, b = 10; +// MethodB(ref a, ref b); +// Console.WriteLine("Method A: {0},{1}", a, b); +// } + +// public void MethodB(ref int a, ref int b) +// { +// Console.WriteLine("Method B: {0},{1}", a, b); +// a *= 2; b *= 2; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch03/Listing 3-5.cs b/9781430248606_sourcecode/Ch03/Listing 3-5.cs new file mode 100644 index 0000000..f5817ab --- /dev/null +++ b/9781430248606_sourcecode/Ch03/Listing 3-5.cs @@ -0,0 +1,33 @@ +//namespace Ch02 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int aInt = 2012; +// TestClass aTestClass = new TestClass(); +// AInterface aInterfaceImplementation = new InterfaceImplementation(); +// AStruct aAStruct = new AStruct(); +// } +// } + +// public class TestClass +// { +// public void TestMethod() {/*Code removed*/} +// } + +// public interface AInterface +// { +// void AMethod(); +// } + +// public class InterfaceImplementation : AInterface +// { +// public void AMethod() {/*Code removed*/} +// } + +// public struct AStruct +// { +// public int ANumber { get; set; } +// } +//} diff --git a/9781430248606_sourcecode/Ch03/Listing 3-6.cs b/9781430248606_sourcecode/Ch03/Listing 3-6.cs new file mode 100644 index 0000000..f5817ab --- /dev/null +++ b/9781430248606_sourcecode/Ch03/Listing 3-6.cs @@ -0,0 +1,33 @@ +//namespace Ch02 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int aInt = 2012; +// TestClass aTestClass = new TestClass(); +// AInterface aInterfaceImplementation = new InterfaceImplementation(); +// AStruct aAStruct = new AStruct(); +// } +// } + +// public class TestClass +// { +// public void TestMethod() {/*Code removed*/} +// } + +// public interface AInterface +// { +// void AMethod(); +// } + +// public class InterfaceImplementation : AInterface +// { +// public void AMethod() {/*Code removed*/} +// } + +// public struct AStruct +// { +// public int ANumber { get; set; } +// } +//} diff --git a/9781430248606_sourcecode/Ch03/Listing 3-7.cs b/9781430248606_sourcecode/Ch03/Listing 3-7.cs new file mode 100644 index 0000000..4feee73 --- /dev/null +++ b/9781430248606_sourcecode/Ch03/Listing 3-7.cs @@ -0,0 +1,41 @@ +//using System; + +//namespace Ch03 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// ObjectAsValue temp = new ObjectAsValue(); +// temp.MethodA(); +// } +// } + +// public class ObjectAsValue +// { +// public ObjectAsValue() +// { +// Console.WriteLine("Object as value"); +// } +// public void MethodA() +// { +// Person aPerson = new Person() +// { +// Name = "APerson" +// }; +// MethodB(aPerson); +// Console.WriteLine("Method A: {0}", aPerson.Name); +// } +// public void MethodB(Person aPerson) +// { +// Console.WriteLine("Method B: {0}", aPerson.Name); +// aPerson.Name = "Updated" + aPerson.Name; +// } +// } + +// public class Person +// { +// public string Name +// { get; set; } +// } +//} diff --git a/9781430248606_sourcecode/Ch03/Program.cs b/9781430248606_sourcecode/Ch03/Program.cs new file mode 100644 index 0000000..18396c6 --- /dev/null +++ b/9781430248606_sourcecode/Ch03/Program.cs @@ -0,0 +1,21 @@ +using System; + +namespace Ch03 +{ + class Program + { + static void Main(string[] args) + { + GetNameWithDefaultValue(); + GetNameWithDefaultValue("Expert C# 5.0 by Mohammad Rahman", "C#"); + } + + public static void GetNameWithDefaultValue( + string name = "Expert C# 5.0: with the .NET 4.5 Framework", + string language = ": C#") + { + Console.WriteLine("{0} {1}", name, language); + } + } +} + diff --git a/9781430248606_sourcecode/Ch03/Properties/AssemblyInfo.cs b/9781430248606_sourcecode/Ch03/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5387806 --- /dev/null +++ b/9781430248606_sourcecode/Ch03/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ch03")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ch03")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7af71ae9-ad9e-4299-98b5-98f1d7e8f104")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9781430248606_sourcecode/Ch03/app.config b/9781430248606_sourcecode/Ch03/app.config new file mode 100644 index 0000000..c5e1dae --- /dev/null +++ b/9781430248606_sourcecode/Ch03/app.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch03/bin/Debug/Ch03.vshost.exe b/9781430248606_sourcecode/Ch03/bin/Debug/Ch03.vshost.exe new file mode 100644 index 0000000..bb84a51 Binary files /dev/null and b/9781430248606_sourcecode/Ch03/bin/Debug/Ch03.vshost.exe differ diff --git a/9781430248606_sourcecode/Ch03/bin/Debug/Ch03.vshost.exe.config b/9781430248606_sourcecode/Ch03/bin/Debug/Ch03.vshost.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch03/bin/Debug/Ch03.vshost.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch03/bin/Debug/Ch03.vshost.exe.manifest b/9781430248606_sourcecode/Ch03/bin/Debug/Ch03.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/9781430248606_sourcecode/Ch03/bin/Debug/Ch03.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/9781430248606_sourcecode/Ch03/bin/Release/Ch03.exe b/9781430248606_sourcecode/Ch03/bin/Release/Ch03.exe new file mode 100644 index 0000000..28aada5 Binary files /dev/null and b/9781430248606_sourcecode/Ch03/bin/Release/Ch03.exe differ diff --git a/9781430248606_sourcecode/Ch03/bin/Release/Ch03.exe.config b/9781430248606_sourcecode/Ch03/bin/Release/Ch03.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch03/bin/Release/Ch03.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch03/bin/Release/Ch03.pdb b/9781430248606_sourcecode/Ch03/bin/Release/Ch03.pdb new file mode 100644 index 0000000..a351b22 Binary files /dev/null and b/9781430248606_sourcecode/Ch03/bin/Release/Ch03.pdb differ diff --git a/9781430248606_sourcecode/Ch03/bin/Release/Ch03.vshost.exe b/9781430248606_sourcecode/Ch03/bin/Release/Ch03.vshost.exe new file mode 100644 index 0000000..bb84a51 Binary files /dev/null and b/9781430248606_sourcecode/Ch03/bin/Release/Ch03.vshost.exe differ diff --git a/9781430248606_sourcecode/Ch03/bin/Release/Ch03.vshost.exe.config b/9781430248606_sourcecode/Ch03/bin/Release/Ch03.vshost.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch03/bin/Release/Ch03.vshost.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch03/bin/Release/Ch03.vshost.exe.manifest b/9781430248606_sourcecode/Ch03/bin/Release/Ch03.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/9781430248606_sourcecode/Ch03/bin/Release/Ch03.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/9781430248606_sourcecode/Ch03/obj/x86/Debug/Ch03.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch03/obj/x86/Debug/Ch03.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..a53e1a9 --- /dev/null +++ b/9781430248606_sourcecode/Ch03/obj/x86/Debug/Ch03.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch03\bin\Debug\Ch03.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch03\bin\Debug\Ch03.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch03\bin\Debug\Ch03.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch03\obj\x86\Debug\Ch03.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch03\obj\x86\Debug\Ch03.pdb diff --git a/9781430248606_sourcecode/Ch03/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch03/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..89727dc Binary files /dev/null and b/9781430248606_sourcecode/Ch03/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch03/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/9781430248606_sourcecode/Ch03/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch03/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/9781430248606_sourcecode/Ch03/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch03/obj/x86/Release/Ch03.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch03/obj/x86/Release/Ch03.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..d3ed545 --- /dev/null +++ b/9781430248606_sourcecode/Ch03/obj/x86/Release/Ch03.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch03\bin\Release\Ch03.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch03\bin\Release\Ch03.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch03\bin\Release\Ch03.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch03\obj\x86\Release\ResolveAssemblyReference.cache +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch03\obj\x86\Release\Ch03.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch03\obj\x86\Release\Ch03.pdb diff --git a/9781430248606_sourcecode/Ch03/obj/x86/Release/Ch03.exe b/9781430248606_sourcecode/Ch03/obj/x86/Release/Ch03.exe new file mode 100644 index 0000000..28aada5 Binary files /dev/null and b/9781430248606_sourcecode/Ch03/obj/x86/Release/Ch03.exe differ diff --git a/9781430248606_sourcecode/Ch03/obj/x86/Release/Ch03.pdb b/9781430248606_sourcecode/Ch03/obj/x86/Release/Ch03.pdb new file mode 100644 index 0000000..a351b22 Binary files /dev/null and b/9781430248606_sourcecode/Ch03/obj/x86/Release/Ch03.pdb differ diff --git a/9781430248606_sourcecode/Ch03/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch03/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..eb20e4a Binary files /dev/null and b/9781430248606_sourcecode/Ch03/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch04/Ch04.csproj b/9781430248606_sourcecode/Ch04/Ch04.csproj new file mode 100644 index 0000000..9969f62 --- /dev/null +++ b/9781430248606_sourcecode/Ch04/Ch04.csproj @@ -0,0 +1,68 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {D595E1D6-0386-47FF-98B6-1287D3D93ACF} + Exe + Properties + Ch04 + Ch04 + v4.5 + + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch04/Listing 4-1.cs b/9781430248606_sourcecode/Ch04/Listing 4-1.cs new file mode 100644 index 0000000..a4a8fde --- /dev/null +++ b/9781430248606_sourcecode/Ch04/Listing 4-1.cs @@ -0,0 +1,37 @@ +//using System; + +//namespace Ch04 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int valueOfA = 10, valueOfB = 20; +// Calculator calculator = new Calculator(); + +// Console.WriteLine("The sum using instance method \t{0} \nand using static method \t{1}", +// calculator.Add(valueOfA, valueOfB), +// CalculatorAsStatic.Add(valueOfA, valueOfB)); +// } +// } + +// public class Calculator +// { +// public int Add(int a, int b) /* An extra this parameter will be added in behind the +// * scene to the Parameters section of Add methods +// * stack */ +// { +// return a + b; +// } +// } + +// public static class CalculatorAsStatic +// { +// public static int Add(int a, int b) /* No extra this parameter will be added to the +// * Parameters section of Add methods +// * stack */ +// { +// return a + b; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch04/Listing 4-10.cs b/9781430248606_sourcecode/Ch04/Listing 4-10.cs new file mode 100644 index 0000000..185eb30 --- /dev/null +++ b/9781430248606_sourcecode/Ch04/Listing 4-10.cs @@ -0,0 +1,28 @@ +//using System; + +//namespace Ch04 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Calculator calculator = new Calculator(); +// Console.WriteLine(calculator.Sub(10, 5)); +// } +// } +// public static class Ch04_ExtensionMethods /* A Static class defined */ +// { +// public static int Sub(this Calculator calculator, int a, int b) +// { +// return a > b ? a - b : b - a; +// } +// } + +// public class Calculator +// { +// public int Add(int a, int b) +// { +// return a + b; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch04/Listing 4-2.cs b/9781430248606_sourcecode/Ch04/Listing 4-2.cs new file mode 100644 index 0000000..35724ca --- /dev/null +++ b/9781430248606_sourcecode/Ch04/Listing 4-2.cs @@ -0,0 +1,32 @@ +//using System; + +//namespace Ch04 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int valueOfA = 10, +// valueOfB = 20, +// increment = 2; /* Used as the external or captured variable +// * for the anonymous method */ +// Calculator calculator = new Calculator(); + +// Console.WriteLine("The sum is \t:{0}", calculator.Add +// (delegate(int a, int b) /* Anonymous method declaration */ +// { +// return a + b + increment; /* increment is the outer variable */ +// }, valueOfA, valueOfB)); +// } +// } + +// public class Calculator +// { +// public delegate int Adder(int a, int b); + +// public int Add(Adder adder, int a, int b) +// { +// return adder(a, b); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch04/Listing 4-6.cs b/9781430248606_sourcecode/Ch04/Listing 4-6.cs new file mode 100644 index 0000000..997e6bb --- /dev/null +++ b/9781430248606_sourcecode/Ch04/Listing 4-6.cs @@ -0,0 +1,27 @@ +//using System; + +//namespace Ch04 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// string data = "abcd"; +// Console.WriteLine("{0}", data.GetLastCharacter()); /* Calls extension defined for the string type. */ +// } +// } +// public static class Ch04_ExtensionMethods /* A Static class defined */ +// { +// public static string GetLastCharacter(this string data) /* A static method with the parameter +// * this along with the type name string */ +// { +// if (data == null || data == string.Empty) +// return string.Empty; +// return data[data.Length - 1].ToString(); +// } +// public static Int32 GetNum(this Int32 dd) +// { +// return dd; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch04/Listing 4-9.cs b/9781430248606_sourcecode/Ch04/Listing 4-9.cs new file mode 100644 index 0000000..f84cf10 --- /dev/null +++ b/9781430248606_sourcecode/Ch04/Listing 4-9.cs @@ -0,0 +1,30 @@ +//namespace Ch04 +//{ +// using System; + +// /* CH04_Extensions has to declare here otherwise compiler-time error occurred. */ +// using Ch04_Extensions; + +// class Program +// { +// static void Main(string[] args) +// { +// string data = "abcd"; +// Console.WriteLine("{0}", data.GetLastCharacter()); +// } +// } +//} + +///* Extension method defined in the Ch04_ExtensionMethods class which reside +// * in the Ch04_Extensions namespace */ +//namespace Ch04_Extensions +//{ +// public static class Ch04_ExtensionMethods +// { +// public static string GetLastCharacter(this string data) +// { +// if (data == null || data == string.Empty) return string.Empty; +// return data[data.Length - 1].ToString(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch04/Program.cs b/9781430248606_sourcecode/Ch04/Program.cs new file mode 100644 index 0000000..2773b3c --- /dev/null +++ b/9781430248606_sourcecode/Ch04/Program.cs @@ -0,0 +1,32 @@ +using System; + +namespace Ch04 +{ + class Program + { + static void Main(string[] args) + { + int valueOfA = 10, valueOfB = 20; + Calculator calculator = new Calculator(); + Console.WriteLine("The sum using instance method \t{0} \nand using static method \t{1}", + calculator.Add(valueOfA, valueOfB), + CalculatorAsStatic.Add(valueOfA, valueOfB)); + } + } + + public class Calculator + { + public int Add(int a, int b) + { + return a + b; + } + } + + public static class CalculatorAsStatic + { + public static int Add(int a, int b) + { + return a + b; + } + } +} \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch04/Properties/AssemblyInfo.cs b/9781430248606_sourcecode/Ch04/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5615dcb --- /dev/null +++ b/9781430248606_sourcecode/Ch04/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ch04")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ch04")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("861c876a-e0f2-4358-9149-60620feb4693")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9781430248606_sourcecode/Ch04/app.config b/9781430248606_sourcecode/Ch04/app.config new file mode 100644 index 0000000..c5e1dae --- /dev/null +++ b/9781430248606_sourcecode/Ch04/app.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch04/bin/Debug/Ch04.vshost.exe b/9781430248606_sourcecode/Ch04/bin/Debug/Ch04.vshost.exe new file mode 100644 index 0000000..bb84a51 Binary files /dev/null and b/9781430248606_sourcecode/Ch04/bin/Debug/Ch04.vshost.exe differ diff --git a/9781430248606_sourcecode/Ch04/bin/Debug/Ch04.vshost.exe.config b/9781430248606_sourcecode/Ch04/bin/Debug/Ch04.vshost.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch04/bin/Debug/Ch04.vshost.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch04/bin/Debug/Ch04.vshost.exe.manifest b/9781430248606_sourcecode/Ch04/bin/Debug/Ch04.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/9781430248606_sourcecode/Ch04/bin/Debug/Ch04.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/9781430248606_sourcecode/Ch04/bin/Release/Ch04.exe b/9781430248606_sourcecode/Ch04/bin/Release/Ch04.exe new file mode 100644 index 0000000..7754fb3 Binary files /dev/null and b/9781430248606_sourcecode/Ch04/bin/Release/Ch04.exe differ diff --git a/9781430248606_sourcecode/Ch04/bin/Release/Ch04.exe.config b/9781430248606_sourcecode/Ch04/bin/Release/Ch04.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch04/bin/Release/Ch04.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch04/bin/Release/Ch04.pdb b/9781430248606_sourcecode/Ch04/bin/Release/Ch04.pdb new file mode 100644 index 0000000..7602597 Binary files /dev/null and b/9781430248606_sourcecode/Ch04/bin/Release/Ch04.pdb differ diff --git a/9781430248606_sourcecode/Ch04/obj/x86/Debug/Ch04.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch04/obj/x86/Debug/Ch04.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..3a45e7d --- /dev/null +++ b/9781430248606_sourcecode/Ch04/obj/x86/Debug/Ch04.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch04\bin\Debug\Ch04.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch04\bin\Debug\Ch04.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch04\bin\Debug\Ch04.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch04\obj\x86\Debug\Ch04.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch04\obj\x86\Debug\Ch04.pdb diff --git a/9781430248606_sourcecode/Ch04/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch04/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..e8658f5 Binary files /dev/null and b/9781430248606_sourcecode/Ch04/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch04/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/9781430248606_sourcecode/Ch04/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch04/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/9781430248606_sourcecode/Ch04/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch04/obj/x86/Release/Ch04.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch04/obj/x86/Release/Ch04.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..09f2580 --- /dev/null +++ b/9781430248606_sourcecode/Ch04/obj/x86/Release/Ch04.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch04\bin\Release\Ch04.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch04\bin\Release\Ch04.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch04\bin\Release\Ch04.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch04\obj\x86\Release\ResolveAssemblyReference.cache +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch04\obj\x86\Release\Ch04.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch04\obj\x86\Release\Ch04.pdb diff --git a/9781430248606_sourcecode/Ch04/obj/x86/Release/Ch04.exe b/9781430248606_sourcecode/Ch04/obj/x86/Release/Ch04.exe new file mode 100644 index 0000000..7754fb3 Binary files /dev/null and b/9781430248606_sourcecode/Ch04/obj/x86/Release/Ch04.exe differ diff --git a/9781430248606_sourcecode/Ch04/obj/x86/Release/Ch04.pdb b/9781430248606_sourcecode/Ch04/obj/x86/Release/Ch04.pdb new file mode 100644 index 0000000..7602597 Binary files /dev/null and b/9781430248606_sourcecode/Ch04/obj/x86/Release/Ch04.pdb differ diff --git a/9781430248606_sourcecode/Ch04/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch04/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..0bf885f Binary files /dev/null and b/9781430248606_sourcecode/Ch04/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch05/Ch05.csproj b/9781430248606_sourcecode/Ch05/Ch05.csproj new file mode 100644 index 0000000..494ba56 --- /dev/null +++ b/9781430248606_sourcecode/Ch05/Ch05.csproj @@ -0,0 +1,68 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {F41576AF-3F4C-4BE0-8A8C-42C5E6A2B8B4} + Exe + Properties + Ch05 + Ch05 + v4.5 + + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch05/Listing 5-1.cs b/9781430248606_sourcecode/Ch05/Listing 5-1.cs new file mode 100644 index 0000000..20b4254 --- /dev/null +++ b/9781430248606_sourcecode/Ch05/Listing 5-1.cs @@ -0,0 +1,41 @@ +//namespace Ch05 +//{ +// public class Book +// { +// private string name; /* name field to define Book*/ +// private int publishedYear; /* publishedYear field to define Book*/ +// private string author; /* author field to define Book*/ + +// public Book() +// { +// name = default(string); +// publishedYear = default(int); +// author = default(string); +// } + +// public Book(string nameOfTheBook, int publishedYearOfTheBook, string authorOfTheBook) +// { +// name = nameOfTheBook; +// publishedYear = publishedYearOfTheBook; +// author = authorOfTheBook; +// } + +// /* A method to get the value of name field */ +// public string GetName() { return name; } + +// /* A method to set the value of name field */ +// public void SetName(string nameOfTheBook) { name = nameOfTheBook; } + +// /* A method to get the value of publishedYear field */ +// public int GetPublishedYear() { return publishedYear; } + +// /* A method to set the value of publishedYear field */ +// public void SetPublishedYear(int publishedYearOfTheBook) { publishedYear = publishedYearOfTheBook; } + +// /* A method to get the value of author field */ +// public string GetAuthor() { return author; } + +// /* A method to set the value of author field */ +// public void SetAuthor(string authorOfTheBook) { author = authorOfTheBook; } +// } +//} diff --git a/9781430248606_sourcecode/Ch05/Listing 5-11.cs b/9781430248606_sourcecode/Ch05/Listing 5-11.cs new file mode 100644 index 0000000..88f3ca3 --- /dev/null +++ b/9781430248606_sourcecode/Ch05/Listing 5-11.cs @@ -0,0 +1,33 @@ +using System; + +namespace Ch05 +{ + class Program + { + static void Main(string[] args) + { + var anObjectOfAnonymousType = new /* Anonymous type definition*/ + { + Name = "Expert C# 5.0: with the .NET 4.5 Framework", /* a string type */ + Language = "C#", /* a string type */ + PublishedOn = 2012, /* a int type */ + Description = new DescriptionAboutBook("This book is about C#") /* a DescriptionAboutBook + * type */ + }; + + Console.WriteLine("{0}\n{1}\n{2}\n{3}", + anObjectOfAnonymousType.Name, + anObjectOfAnonymousType.Language, + anObjectOfAnonymousType.PublishedOn, + anObjectOfAnonymousType.Description.Description); + } + } + public class DescriptionAboutBook + { + public DescriptionAboutBook(string data) + { + Description = data; + } + public string Description { get; set; } + } +} diff --git a/9781430248606_sourcecode/Ch05/Listing 5-2.cs b/9781430248606_sourcecode/Ch05/Listing 5-2.cs new file mode 100644 index 0000000..87a7b58 --- /dev/null +++ b/9781430248606_sourcecode/Ch05/Listing 5-2.cs @@ -0,0 +1,41 @@ +//namespace Ch05 +//{ +// public class Book +// { +// private string name; +// private int publishedYear; +// private string author; + +// public Book() +// { +// name = default(string); +// publishedYear = default(int); +// author = default(string); +// } + +// public Book(string nameOfTheBook, int publishedYearOfTheBook, string authorOfTheBook) +// { +// name = nameOfTheBook; +// publishedYear = publishedYearOfTheBook; +// author = authorOfTheBook; +// } + +// public string Name /* Name property */ +// { +// get { return name; } +// set { name = value; } +// } + +// public int PublishedYear /* PublishedYear property */ +// { +// get { return publishedYear; } +// set { publishedYear = value; } +// } + +// public string Author /* Author property */ +// { +// get { return author; } +// set { author = value; } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch05/Listing 5-5.cs b/9781430248606_sourcecode/Ch05/Listing 5-5.cs new file mode 100644 index 0000000..fc1c376 --- /dev/null +++ b/9781430248606_sourcecode/Ch05/Listing 5-5.cs @@ -0,0 +1,30 @@ +//namespace Ch05 +//{ +// public class Book +// { +// /* Assigning default value to the Property */ +// public Book() +// { +// Name = default(string); +// PublishedYear = default(int); +// Author = default(string); +// } + +// /* Assigning value to the Property */ +// public Book(string nameOfTheBook, int publishedYearOfTheBook, string authorOfTheBook) +// { +// Name = nameOfTheBook; +// PublishedYear = publishedYearOfTheBook; +// Author = authorOfTheBook; +// } + +// /* Automatic property declaration for the Name */ +// public string Name { get; set; } + +// /* Automatic property declaration for the PublishedYear */ +// public int PublishedYear { get; set; } + +// /* Automatic property declaration for the Author */ +// public string Author { get; set; } +// } +//} diff --git a/9781430248606_sourcecode/Ch05/Listing 5-8.cs b/9781430248606_sourcecode/Ch05/Listing 5-8.cs new file mode 100644 index 0000000..bbf22e7 --- /dev/null +++ b/9781430248606_sourcecode/Ch05/Listing 5-8.cs @@ -0,0 +1,28 @@ +//using System; + +//namespace Ch05 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// var person = new Person /* type of Person */ +// { +// Name = "A Person" +// }; +// var personAge = 30; /* type of int */ +// var authorOf = "Expert C# 5.0: with the .NET 4.5 Framework"; /* type of string */ + +// Console.WriteLine("Name:{0}\nAge: {1}\nBook: {2}", person.Name, personAge, authorOf); +// } +// } + +// public class Person +// { +// public string Name +// { +// get; +// set; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch05/Program.cs b/9781430248606_sourcecode/Ch05/Program.cs new file mode 100644 index 0000000..86672db --- /dev/null +++ b/9781430248606_sourcecode/Ch05/Program.cs @@ -0,0 +1,32 @@ +//using System; + +//namespace Ch05 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// var anObjectOfAnonymousType = new +// { +// Name = "Expert C# 5.0: with the .NET 4.5 Framework", +// Language = "C#", +// PublishedOn = 2012, +// Description = new DescriptionAboutBook("This book is about C#") +// }; + +// Console.WriteLine("{0}\n{1}\n{2}\n{3}", +// anObjectOfAnonymousType.Name, +// anObjectOfAnonymousType.Language, +// anObjectOfAnonymousType.PublishedOn, +// anObjectOfAnonymousType.Description.Description); +// } +// } +// public class DescriptionAboutBook +// { +// public DescriptionAboutBook(string data) +// { +// Description = data; +// } +// public string Description { get; set; } +// } +//} \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch05/Properties/AssemblyInfo.cs b/9781430248606_sourcecode/Ch05/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a7d7ca3 --- /dev/null +++ b/9781430248606_sourcecode/Ch05/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ch05")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ch05")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9f6def6c-6394-44ae-acd3-3ced50515ea8")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9781430248606_sourcecode/Ch05/app.config b/9781430248606_sourcecode/Ch05/app.config new file mode 100644 index 0000000..c5e1dae --- /dev/null +++ b/9781430248606_sourcecode/Ch05/app.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch05/bin/Debug/Ch05.vshost.exe b/9781430248606_sourcecode/Ch05/bin/Debug/Ch05.vshost.exe new file mode 100644 index 0000000..bb84a51 Binary files /dev/null and b/9781430248606_sourcecode/Ch05/bin/Debug/Ch05.vshost.exe differ diff --git a/9781430248606_sourcecode/Ch05/bin/Debug/Ch05.vshost.exe.config b/9781430248606_sourcecode/Ch05/bin/Debug/Ch05.vshost.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch05/bin/Debug/Ch05.vshost.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch05/bin/Debug/Ch05.vshost.exe.manifest b/9781430248606_sourcecode/Ch05/bin/Debug/Ch05.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/9781430248606_sourcecode/Ch05/bin/Debug/Ch05.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/9781430248606_sourcecode/Ch05/bin/Release/Ch05.exe b/9781430248606_sourcecode/Ch05/bin/Release/Ch05.exe new file mode 100644 index 0000000..62f01de Binary files /dev/null and b/9781430248606_sourcecode/Ch05/bin/Release/Ch05.exe differ diff --git a/9781430248606_sourcecode/Ch05/bin/Release/Ch05.exe.config b/9781430248606_sourcecode/Ch05/bin/Release/Ch05.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch05/bin/Release/Ch05.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch05/bin/Release/Ch05.pdb b/9781430248606_sourcecode/Ch05/bin/Release/Ch05.pdb new file mode 100644 index 0000000..34fa465 Binary files /dev/null and b/9781430248606_sourcecode/Ch05/bin/Release/Ch05.pdb differ diff --git a/9781430248606_sourcecode/Ch05/obj/x86/Debug/Ch05.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch05/obj/x86/Debug/Ch05.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..076ab5d --- /dev/null +++ b/9781430248606_sourcecode/Ch05/obj/x86/Debug/Ch05.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch05\bin\Debug\Ch05.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch05\bin\Debug\Ch05.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch05\bin\Debug\Ch05.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch05\obj\x86\Debug\Ch05.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch05\obj\x86\Debug\Ch05.pdb diff --git a/9781430248606_sourcecode/Ch05/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch05/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..a8967c4 Binary files /dev/null and b/9781430248606_sourcecode/Ch05/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch05/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/9781430248606_sourcecode/Ch05/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch05/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/9781430248606_sourcecode/Ch05/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch05/obj/x86/Release/Ch05.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch05/obj/x86/Release/Ch05.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..78eeaa9 --- /dev/null +++ b/9781430248606_sourcecode/Ch05/obj/x86/Release/Ch05.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch05\bin\Release\Ch05.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch05\bin\Release\Ch05.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch05\bin\Release\Ch05.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch05\obj\x86\Release\ResolveAssemblyReference.cache +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch05\obj\x86\Release\Ch05.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch05\obj\x86\Release\Ch05.pdb diff --git a/9781430248606_sourcecode/Ch05/obj/x86/Release/Ch05.exe b/9781430248606_sourcecode/Ch05/obj/x86/Release/Ch05.exe new file mode 100644 index 0000000..62f01de Binary files /dev/null and b/9781430248606_sourcecode/Ch05/obj/x86/Release/Ch05.exe differ diff --git a/9781430248606_sourcecode/Ch05/obj/x86/Release/Ch05.pdb b/9781430248606_sourcecode/Ch05/obj/x86/Release/Ch05.pdb new file mode 100644 index 0000000..34fa465 Binary files /dev/null and b/9781430248606_sourcecode/Ch05/obj/x86/Release/Ch05.pdb differ diff --git a/9781430248606_sourcecode/Ch05/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch05/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..aba1150 Binary files /dev/null and b/9781430248606_sourcecode/Ch05/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch06/Ch06.csproj b/9781430248606_sourcecode/Ch06/Ch06.csproj new file mode 100644 index 0000000..5a2ee12 --- /dev/null +++ b/9781430248606_sourcecode/Ch06/Ch06.csproj @@ -0,0 +1,68 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {1ABE6AC4-49BD-425E-8C55-C31DC9709611} + Exe + Properties + Ch06 + Ch06 + v4.5 + + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch06/Listing 6-1.cs b/9781430248606_sourcecode/Ch06/Listing 6-1.cs new file mode 100644 index 0000000..7c28dc0 --- /dev/null +++ b/9781430248606_sourcecode/Ch06/Listing 6-1.cs @@ -0,0 +1,24 @@ +//namespace Ch06 +//{ +// class Program +// { +// public enum Planets +// { +// Sun = 0, /* Otherwise compiler will assign default value */ +// Mercury, /* C# compiler will assign 1 */ +// Venus, /* C# compiler will assign 2 */ +// Earth, /* C# compiler will assign 3 */ +// Mars, /* C# compiler will assign 4 */ +// Jupiter, /* C# compiler will assign 5 */ +// Saturn, /* C# compiler will assign 6 */ +// Uranus, /* C# compiler will assign 7 */ +// Neptune /* C# compiler will assign 8 */ +// } + +// static void Main(string[] args) +// { +// Planets planets = new Planets(); +// planets = Planets.Earth; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch06/Listing 6-5.cs b/9781430248606_sourcecode/Ch06/Listing 6-5.cs new file mode 100644 index 0000000..5ea6d0f --- /dev/null +++ b/9781430248606_sourcecode/Ch06/Listing 6-5.cs @@ -0,0 +1,26 @@ +//using System; +//using System.Linq; + +//namespace Ch06 +//{ +// class Program +// { +// public enum Planets +// { +// Sun = 0, /* Otherwise compiler will assign default value */ +// Mercury, /* compiler will assign 1 */ +// Venus, /* compiler will assign 2 */ +// Earth, /* compiler will assign 3 */ +// Mars, /* compiler will assign 4 */ +// Jupiter, /* compiler will assign 5 */ +// Saturn, /* compiler will assign 6 */ +// Uranus, /* compiler will assign 7 */ +// Neptune /* compiler will assign 8 */ +// } + +// static void Main(string[] args) +// { +// Enum.GetNames(typeof(Planets)).ToList().ForEach(name => Console.Write(name + "\t")); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch06/Listing 6-6.cs b/9781430248606_sourcecode/Ch06/Listing 6-6.cs new file mode 100644 index 0000000..d27c04b --- /dev/null +++ b/9781430248606_sourcecode/Ch06/Listing 6-6.cs @@ -0,0 +1,27 @@ +//using System; +//using System.Linq; + +//namespace Ch06 +//{ +// class Program +// { +// public enum Planets +// { +// Sun = 0, /* Otherwise compiler will assign default value */ +// Mercury, /* compiler will assign 1 */ +// Venus, /* compiler will assign 2 */ +// Earth, /* compiler will assign 3 */ +// Mars, /* compiler will assign 4 */ +// Jupiter, /* compiler will assign 5 */ +// Saturn, /* compiler will assign 6 */ +// Uranus, /* compiler will assign 7 */ +// Neptune /* compiler will assign 8 */ +// } + +// static void Main(string[] args) +// { +// Enum.GetValues(typeof(Planets)).Cast().ToList().ForEach( +//name => Console.Write(name + "\t")); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch06/Listing 6-7.cs b/9781430248606_sourcecode/Ch06/Listing 6-7.cs new file mode 100644 index 0000000..7ca9640 --- /dev/null +++ b/9781430248606_sourcecode/Ch06/Listing 6-7.cs @@ -0,0 +1,30 @@ +//using System; +//using System.Linq; + +//namespace Ch06 +//{ +// class Program +// { +// public enum Planets +// { +// Sun = 0, /* Otherwise compiler will assign default value */ +// Mercury, /* compiler will assign 1 */ +// Venus, /* compiler will assign 2 */ +// Earth, /* compiler will assign 3 */ +// Mars, /* compiler will assign 4 */ +// Jupiter, /* compiler will assign 5 */ +// Saturn, /* compiler will assign 6 */ +// Uranus, /* compiler will assign 7 */ +// Neptune /* compiler will assign 8 */ +// } + +// static void Main(string[] args) +// { +// string enumItemToFind = "Jupiter"; +// Console.WriteLine( +// "Is {0}, has been defined in the Planets enum? {1}", +// enumItemToFind, +// Enum.IsDefined(typeof(Planets), enumItemToFind)); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch06/Listing 6-8.cs b/9781430248606_sourcecode/Ch06/Listing 6-8.cs new file mode 100644 index 0000000..0cbd3ec --- /dev/null +++ b/9781430248606_sourcecode/Ch06/Listing 6-8.cs @@ -0,0 +1,28 @@ +//using System; +//using System.Linq; + +//namespace Ch06 +//{ +// class Program +// { +// public enum Planets +// { +// Sun = 0, /* Otherwise compiler will assign default value */ +// Mercury, /* compiler will assign 1 */ +// Venus, /* compiler will assign 2 */ +// Earth, /* compiler will assign 3 */ +// Mars, /* compiler will assign 4 */ +// Jupiter, /* compiler will assign 5 */ +// Saturn, /* compiler will assign 6 */ +// Uranus, /* compiler will assign 7 */ +// Neptune /* compiler will assign 8 */ +// } + +// static void Main(string[] args) +// { +// string enumItemToFind = "Jupiter"; +// Planets result; +// bool isParsable = Enum.TryParse(enumItemToFind, true, out result); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch06/Program.cs b/9781430248606_sourcecode/Ch06/Program.cs new file mode 100644 index 0000000..ccd0205 --- /dev/null +++ b/9781430248606_sourcecode/Ch06/Program.cs @@ -0,0 +1,24 @@ +namespace Ch06 +{ + class Program + { + public enum Planets + { + Sun = 0, /* Otherwise compiler will assign default value */ + Mercury, /* C# compiler will assign 1 */ + Venus, /* C# compiler will assign 2 */ + Earth, /* C# compiler will assign 3 */ + Mars, /* C# compiler will assign 4 */ + Jupiter, /* C# compiler will assign 5 */ + Saturn, /* C# compiler will assign 6 */ + Uranus, /* C# compiler will assign 7 */ + Neptune /* C# compiler will assign 8 */ + } + + static void Main(string[] args) + { + Planets planets = new Planets(); + planets = Planets.Earth; + } + } +} diff --git a/9781430248606_sourcecode/Ch06/Properties/AssemblyInfo.cs b/9781430248606_sourcecode/Ch06/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..55b4932 --- /dev/null +++ b/9781430248606_sourcecode/Ch06/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ch06")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ch06")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ccc7b972-0adb-413b-9a6e-354cd5494d12")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9781430248606_sourcecode/Ch06/app.config b/9781430248606_sourcecode/Ch06/app.config new file mode 100644 index 0000000..c5e1dae --- /dev/null +++ b/9781430248606_sourcecode/Ch06/app.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch06/bin/Debug/Ch06.vshost.exe b/9781430248606_sourcecode/Ch06/bin/Debug/Ch06.vshost.exe new file mode 100644 index 0000000..bb84a51 Binary files /dev/null and b/9781430248606_sourcecode/Ch06/bin/Debug/Ch06.vshost.exe differ diff --git a/9781430248606_sourcecode/Ch06/bin/Debug/Ch06.vshost.exe.config b/9781430248606_sourcecode/Ch06/bin/Debug/Ch06.vshost.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch06/bin/Debug/Ch06.vshost.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch06/bin/Debug/Ch06.vshost.exe.manifest b/9781430248606_sourcecode/Ch06/bin/Debug/Ch06.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/9781430248606_sourcecode/Ch06/bin/Debug/Ch06.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/9781430248606_sourcecode/Ch06/bin/Release/Ch06.exe b/9781430248606_sourcecode/Ch06/bin/Release/Ch06.exe new file mode 100644 index 0000000..856ce9a Binary files /dev/null and b/9781430248606_sourcecode/Ch06/bin/Release/Ch06.exe differ diff --git a/9781430248606_sourcecode/Ch06/bin/Release/Ch06.exe.config b/9781430248606_sourcecode/Ch06/bin/Release/Ch06.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch06/bin/Release/Ch06.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch06/bin/Release/Ch06.pdb b/9781430248606_sourcecode/Ch06/bin/Release/Ch06.pdb new file mode 100644 index 0000000..332b9fa Binary files /dev/null and b/9781430248606_sourcecode/Ch06/bin/Release/Ch06.pdb differ diff --git a/9781430248606_sourcecode/Ch06/obj/x86/Debug/Ch06.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch06/obj/x86/Debug/Ch06.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..721c909 --- /dev/null +++ b/9781430248606_sourcecode/Ch06/obj/x86/Debug/Ch06.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch06\bin\Debug\Ch06.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch06\bin\Debug\Ch06.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch06\bin\Debug\Ch06.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch06\obj\x86\Debug\Ch06.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch06\obj\x86\Debug\Ch06.pdb diff --git a/9781430248606_sourcecode/Ch06/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch06/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..e71d769 Binary files /dev/null and b/9781430248606_sourcecode/Ch06/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch06/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/9781430248606_sourcecode/Ch06/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch06/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/9781430248606_sourcecode/Ch06/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch06/obj/x86/Release/Ch06.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch06/obj/x86/Release/Ch06.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..f1802ec --- /dev/null +++ b/9781430248606_sourcecode/Ch06/obj/x86/Release/Ch06.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch06\bin\Release\Ch06.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch06\bin\Release\Ch06.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch06\bin\Release\Ch06.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch06\obj\x86\Release\ResolveAssemblyReference.cache +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch06\obj\x86\Release\Ch06.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch06\obj\x86\Release\Ch06.pdb diff --git a/9781430248606_sourcecode/Ch06/obj/x86/Release/Ch06.exe b/9781430248606_sourcecode/Ch06/obj/x86/Release/Ch06.exe new file mode 100644 index 0000000..856ce9a Binary files /dev/null and b/9781430248606_sourcecode/Ch06/obj/x86/Release/Ch06.exe differ diff --git a/9781430248606_sourcecode/Ch06/obj/x86/Release/Ch06.pdb b/9781430248606_sourcecode/Ch06/obj/x86/Release/Ch06.pdb new file mode 100644 index 0000000..332b9fa Binary files /dev/null and b/9781430248606_sourcecode/Ch06/obj/x86/Release/Ch06.pdb differ diff --git a/9781430248606_sourcecode/Ch06/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch06/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..d89f37d Binary files /dev/null and b/9781430248606_sourcecode/Ch06/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch07/Ch07.csproj b/9781430248606_sourcecode/Ch07/Ch07.csproj new file mode 100644 index 0000000..1fe71cc --- /dev/null +++ b/9781430248606_sourcecode/Ch07/Ch07.csproj @@ -0,0 +1,67 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {355AD8B6-3A7B-42D3-A769-1C5F2209F492} + Exe + Properties + Ch07 + Ch07 + v4.5 + + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch07/Listing 7-1.cs b/9781430248606_sourcecode/Ch07/Listing 7-1.cs new file mode 100644 index 0000000..184b887 --- /dev/null +++ b/9781430248606_sourcecode/Ch07/Listing 7-1.cs @@ -0,0 +1,35 @@ +//using System; + +//namespace Ch07 +//{ +// class Program +// { +// /* declare a delegate type. */ +// delegate int DelegateOfTheCalculator(int a, int b); + +// static void Main(string[] args) +// { +// DelegateHandler(); +// } + +// static void DelegateHandler() +// { +// StandardCalculator standardCalculator = new StandardCalculator(); + +// DelegateOfTheCalculator delegateOfTheCalculator = +// new DelegateOfTheCalculator(standardCalculator.Add); +// delegateOfTheCalculator += standardCalculator.Sub; +// delegateOfTheCalculator -= standardCalculator.Sub; + +// /* Execute the Add method */ +// Console.WriteLine("Sum of a and b is:{0}", delegateOfTheCalculator(10, 10)); +// } +// } + +// public class StandardCalculator +// { +// public int Add(int a, int b) { return a + b; } +// public int Sub(int a, int b) { return a > b ? a - b : 0; } +// public int Mul(int a, int b) { return a * b; } +// } +//} diff --git a/9781430248606_sourcecode/Ch07/Listing 7-10.cs b/9781430248606_sourcecode/Ch07/Listing 7-10.cs new file mode 100644 index 0000000..d8e1bd6 --- /dev/null +++ b/9781430248606_sourcecode/Ch07/Listing 7-10.cs @@ -0,0 +1,34 @@ +//using System; + +//namespace Ch07 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// ExampleOfFunc exampleOfFunc = new ExampleOfFunc(); + +// Console.WriteLine("{0}", exampleOfFunc.Addition(exampleOfFunc.Add)); +// Console.WriteLine("{0}", exampleOfFunc.Addition( +// () => +// { +// return 100 + 100; +// })); +// } +// } + +// public class ExampleOfFunc +// { +// public int Addition(Func additionImplementor) +// { +// if (additionImplementor != null) +// return additionImplementor(); +// return default(int); +// } + +// public int Add() +// { +// return 1 + 1; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch07/Listing 7-12.cs b/9781430248606_sourcecode/Ch07/Listing 7-12.cs new file mode 100644 index 0000000..0dadc95 --- /dev/null +++ b/9781430248606_sourcecode/Ch07/Listing 7-12.cs @@ -0,0 +1,45 @@ +//using System; + +//namespace Ch07 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// ExampleOfFunc exampleOfFunc = new ExampleOfFunc(); + +// Console.WriteLine("{0}", exampleOfFunc.Addition( +// exampleOfFunc.Add, /* Pass method name */ +// 1, 2, 3, 4, 5)); + +// Console.WriteLine("{0}", exampleOfFunc.Addition( +// (a, b, c, d, e) => +// { +// return a + b + c + d + e; +// }, /* Pass anonymous method */ +// 1, 2, 3, 4, 5)); +// } +// } + +// public class ExampleOfFunc +// { +// public int Addition( +// Func additionImplementor, +// int a, +// int b, +// int c, +// int d, +// int e) +// { +// if (additionImplementor != null) +// return additionImplementor(a, b, c, d, e); + +// return default(int); +// } + +// public int Add(int a, int b, int c, int d, int e) +// { +// return a + b + c + d + e; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch07/Listing 7-16.cs b/9781430248606_sourcecode/Ch07/Listing 7-16.cs new file mode 100644 index 0000000..7d34e37 --- /dev/null +++ b/9781430248606_sourcecode/Ch07/Listing 7-16.cs @@ -0,0 +1,31 @@ +//using System; +//namespace Ch07 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// ExampleOfAction exampleOfAction = new ExampleOfAction(); +// exampleOfAction.Addition(exampleOfAction.Add, 10, 10); +// exampleOfAction.Addition( +// (a, b) => +// { +// Console.WriteLine("{0}", a + b); +// }, 20, 20); +// } +// } + +// public class ExampleOfAction +// { +// public void Addition(Action additionImplementor, int a, int b) +// { +// if (additionImplementor != null) +// additionImplementor(a, b); +// } + +// public void Add(int a, int b) +// { +// Console.WriteLine("{0}", a + b); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch07/Program.cs b/9781430248606_sourcecode/Ch07/Program.cs new file mode 100644 index 0000000..d59c1fa --- /dev/null +++ b/9781430248606_sourcecode/Ch07/Program.cs @@ -0,0 +1,32 @@ +using System; +namespace Ch07 +{ + class Program + { + static void Main(string[] args) + { + ExampleOfFunc exampleOfFunc = new ExampleOfFunc(); + exampleOfFunc.Addition(exampleOfFunc.Add, 10, 10); + exampleOfFunc.Addition( +(a, b) => +{ + Console.WriteLine("{0}", a + b); +}, 20, 20); + } + } + + public class ExampleOfFunc + { + public void Addition(Action additionImplementor, int a, int b) + { + if (additionImplementor != null) + additionImplementor(a, b); + } + + public void Add(int a, int b) + { + Console.WriteLine("{0}", a + b); + } + } +} + diff --git a/9781430248606_sourcecode/Ch07/Properties/AssemblyInfo.cs b/9781430248606_sourcecode/Ch07/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6e846c3 --- /dev/null +++ b/9781430248606_sourcecode/Ch07/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ch07")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ch07")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("29681eec-82f9-4a33-ad59-5c35935b8b46")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9781430248606_sourcecode/Ch07/app.config b/9781430248606_sourcecode/Ch07/app.config new file mode 100644 index 0000000..c5e1dae --- /dev/null +++ b/9781430248606_sourcecode/Ch07/app.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch07/bin/Debug/Ch07.vshost.exe b/9781430248606_sourcecode/Ch07/bin/Debug/Ch07.vshost.exe new file mode 100644 index 0000000..bb84a51 Binary files /dev/null and b/9781430248606_sourcecode/Ch07/bin/Debug/Ch07.vshost.exe differ diff --git a/9781430248606_sourcecode/Ch07/bin/Debug/Ch07.vshost.exe.config b/9781430248606_sourcecode/Ch07/bin/Debug/Ch07.vshost.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch07/bin/Debug/Ch07.vshost.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch07/bin/Debug/Ch07.vshost.exe.manifest b/9781430248606_sourcecode/Ch07/bin/Debug/Ch07.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/9781430248606_sourcecode/Ch07/bin/Debug/Ch07.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/9781430248606_sourcecode/Ch07/bin/Release/Ch07.exe b/9781430248606_sourcecode/Ch07/bin/Release/Ch07.exe new file mode 100644 index 0000000..a86837c Binary files /dev/null and b/9781430248606_sourcecode/Ch07/bin/Release/Ch07.exe differ diff --git a/9781430248606_sourcecode/Ch07/bin/Release/Ch07.exe.config b/9781430248606_sourcecode/Ch07/bin/Release/Ch07.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch07/bin/Release/Ch07.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch07/bin/Release/Ch07.pdb b/9781430248606_sourcecode/Ch07/bin/Release/Ch07.pdb new file mode 100644 index 0000000..aff0be9 Binary files /dev/null and b/9781430248606_sourcecode/Ch07/bin/Release/Ch07.pdb differ diff --git a/9781430248606_sourcecode/Ch07/obj/x86/Debug/Ch07.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch07/obj/x86/Debug/Ch07.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..9044082 --- /dev/null +++ b/9781430248606_sourcecode/Ch07/obj/x86/Debug/Ch07.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch07\bin\Debug\Ch07.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch07\bin\Debug\Ch07.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch07\bin\Debug\Ch07.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch07\obj\x86\Debug\Ch07.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch07\obj\x86\Debug\Ch07.pdb diff --git a/9781430248606_sourcecode/Ch07/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch07/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..be73aee Binary files /dev/null and b/9781430248606_sourcecode/Ch07/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch07/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/9781430248606_sourcecode/Ch07/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch07/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/9781430248606_sourcecode/Ch07/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch07/obj/x86/Release/Ch07.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch07/obj/x86/Release/Ch07.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..39d35a7 --- /dev/null +++ b/9781430248606_sourcecode/Ch07/obj/x86/Release/Ch07.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch07\bin\Release\Ch07.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch07\bin\Release\Ch07.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch07\bin\Release\Ch07.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch07\obj\x86\Release\ResolveAssemblyReference.cache +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch07\obj\x86\Release\Ch07.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch07\obj\x86\Release\Ch07.pdb diff --git a/9781430248606_sourcecode/Ch07/obj/x86/Release/Ch07.exe b/9781430248606_sourcecode/Ch07/obj/x86/Release/Ch07.exe new file mode 100644 index 0000000..a86837c Binary files /dev/null and b/9781430248606_sourcecode/Ch07/obj/x86/Release/Ch07.exe differ diff --git a/9781430248606_sourcecode/Ch07/obj/x86/Release/Ch07.pdb b/9781430248606_sourcecode/Ch07/obj/x86/Release/Ch07.pdb new file mode 100644 index 0000000..aff0be9 Binary files /dev/null and b/9781430248606_sourcecode/Ch07/obj/x86/Release/Ch07.pdb differ diff --git a/9781430248606_sourcecode/Ch07/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch07/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..e0c636a Binary files /dev/null and b/9781430248606_sourcecode/Ch07/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch08/Ch08.csproj b/9781430248606_sourcecode/Ch08/Ch08.csproj new file mode 100644 index 0000000..2216983 --- /dev/null +++ b/9781430248606_sourcecode/Ch08/Ch08.csproj @@ -0,0 +1,63 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {4C3FB5F4-D3A0-4568-8462-093C6D6D3F95} + Exe + Properties + Ch08 + Ch08 + v4.5 + + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch08/Program.cs b/9781430248606_sourcecode/Ch08/Program.cs new file mode 100644 index 0000000..390722b --- /dev/null +++ b/9781430248606_sourcecode/Ch08/Program.cs @@ -0,0 +1,118 @@ +using System; + +namespace Ch08 +{ + class Program + { + static void Main(string[] args) + { + NewsManager nlm = new NewsManager(); + /* Initialize the client of the news manager event. The + * clients will subscribe to the event in the + * initialization time.*/ + Reviewer subscriberOne = new Reviewer(nlm); + Publisher subscriberTwo = new Publisher(nlm); + + /* Some news arrived to the NewsManager to publish and + * notify to the subscribers.*/ + nlm.PublishNews("Higgs particle", + "The Higgs particle is named after Peter Higgs."); + nlm.PublishNews("Expert C# 5.0 with .NET Framework 4.5", + "A about the C# language."); + + /* Finished job so UnSubscribe the events */ + subscriberOne.UnSubscribe(nlm); + subscriberTwo.UnSubscribe(nlm); + + /* Publishing new news but it not going to be notified */ + nlm.PublishNews("10th Dimensional world", + "Still under investigation so don't publish."); + } + } + + public class Reviewer + { + public Reviewer(NewsManager nlm) + { + /* Subscribe to the NewsManager for the notification.*/ + nlm.NewsEvent += ReviewOnArrivedNews; + } + + /* When news arrived if subscribe then execute this method.*/ + private void ReviewOnArrivedNews(object sender, NewsEventArgs na) + { + Console.WriteLine("Reviewed:\n{0},\t{1}", na.Title, na.Detail); + } + + /* To unsubscribe from the NewsEvent */ + public void UnSubscribe(NewsManager nlm) + { + nlm.NewsEvent -= ReviewOnArrivedNews; + } + } + + public class Publisher + { + public Publisher(NewsManager nlm) + { + /* Subscribe to the NewsManager for the notification.*/ + nlm.NewsEvent += PublishArrivedNews; + } + + /* When news arrived if subscribe then execute this method.*/ + private void PublishArrivedNews(object sender, NewsEventArgs na) + { + Console.WriteLine("Published:\n{0} news.", na.Title); + } + + public void UnSubscribe(NewsManager nlm) + { + nlm.NewsEvent -= PublishArrivedNews; + } + } + + public class NewsManager + { + /* An container of the subscribed method to the event. + * Clients can subscribe for the notification via + * NewsEvent event.*/ + public event EventHandler NewsEvent; + + public void PublishNews(string name, string detail) + { + NewsEventArgs na = new NewsEventArgs(name, detail); + + /* If news arrived and ready to publish then call OnNewsArrival + * method which will execute subscribed methods.*/ + OnNewsArrival(na); + } + + /* If anyone subscribe for the notification then this method will + * invoke each of the subscribed method and execute all. */ + protected virtual void OnNewsArrival(NewsEventArgs args) + { + EventHandler newsHandler = NewsEvent; + if (newsHandler != null) + { + newsHandler(this, args); + } + } + } + + public class NewsEventArgs : EventArgs + { + /* Declared few private fields */ + private string title; + private string detail; + + public NewsEventArgs(string TitleOfTheNews, string DetailOfTheNews) + { + title = TitleOfTheNews; + detail = DetailOfTheNews; + } + + /* ReadOnly fields */ + public string Title { get { return title; } } + public string Detail { get { return detail; } } + } +} diff --git a/9781430248606_sourcecode/Ch08/Properties/AssemblyInfo.cs b/9781430248606_sourcecode/Ch08/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..627b352 --- /dev/null +++ b/9781430248606_sourcecode/Ch08/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ch08")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ch08")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("33123ae2-6339-46c0-8b34-c9211a312df6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9781430248606_sourcecode/Ch08/app.config b/9781430248606_sourcecode/Ch08/app.config new file mode 100644 index 0000000..c5e1dae --- /dev/null +++ b/9781430248606_sourcecode/Ch08/app.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch08/bin/Release/Ch08.exe b/9781430248606_sourcecode/Ch08/bin/Release/Ch08.exe new file mode 100644 index 0000000..1d5ca66 Binary files /dev/null and b/9781430248606_sourcecode/Ch08/bin/Release/Ch08.exe differ diff --git a/9781430248606_sourcecode/Ch08/bin/Release/Ch08.exe.config b/9781430248606_sourcecode/Ch08/bin/Release/Ch08.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch08/bin/Release/Ch08.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch08/bin/Release/Ch08.pdb b/9781430248606_sourcecode/Ch08/bin/Release/Ch08.pdb new file mode 100644 index 0000000..de1d2da Binary files /dev/null and b/9781430248606_sourcecode/Ch08/bin/Release/Ch08.pdb differ diff --git a/9781430248606_sourcecode/Ch08/obj/x86/Debug/Ch08.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch08/obj/x86/Debug/Ch08.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..fa15ddd --- /dev/null +++ b/9781430248606_sourcecode/Ch08/obj/x86/Debug/Ch08.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch08\bin\Debug\Ch08.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch08\bin\Debug\Ch08.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch08\bin\Debug\Ch08.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch08\obj\x86\Debug\Ch08.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch08\obj\x86\Debug\Ch08.pdb diff --git a/9781430248606_sourcecode/Ch08/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch08/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..1a54502 Binary files /dev/null and b/9781430248606_sourcecode/Ch08/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch08/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/9781430248606_sourcecode/Ch08/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch08/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/9781430248606_sourcecode/Ch08/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch08/obj/x86/Release/Ch08.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch08/obj/x86/Release/Ch08.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..201118d --- /dev/null +++ b/9781430248606_sourcecode/Ch08/obj/x86/Release/Ch08.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch08\bin\Release\Ch08.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch08\bin\Release\Ch08.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch08\bin\Release\Ch08.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch08\obj\x86\Release\ResolveAssemblyReference.cache +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch08\obj\x86\Release\Ch08.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch08\obj\x86\Release\Ch08.pdb diff --git a/9781430248606_sourcecode/Ch08/obj/x86/Release/Ch08.exe b/9781430248606_sourcecode/Ch08/obj/x86/Release/Ch08.exe new file mode 100644 index 0000000..1d5ca66 Binary files /dev/null and b/9781430248606_sourcecode/Ch08/obj/x86/Release/Ch08.exe differ diff --git a/9781430248606_sourcecode/Ch08/obj/x86/Release/Ch08.pdb b/9781430248606_sourcecode/Ch08/obj/x86/Release/Ch08.pdb new file mode 100644 index 0000000..de1d2da Binary files /dev/null and b/9781430248606_sourcecode/Ch08/obj/x86/Release/Ch08.pdb differ diff --git a/9781430248606_sourcecode/Ch08/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch08/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..570b1ec Binary files /dev/null and b/9781430248606_sourcecode/Ch08/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch09/Ch09.csproj b/9781430248606_sourcecode/Ch09/Ch09.csproj new file mode 100644 index 0000000..b94034b --- /dev/null +++ b/9781430248606_sourcecode/Ch09/Ch09.csproj @@ -0,0 +1,66 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {8D8C5025-7DE6-4199-BD89-2AA6D0F57FB6} + Exe + Properties + Ch09 + Ch09 + v4.5 + + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + false + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch09/Listing 9-1.cs b/9781430248606_sourcecode/Ch09/Listing 9-1.cs new file mode 100644 index 0000000..ff6642a --- /dev/null +++ b/9781430248606_sourcecode/Ch09/Listing 9-1.cs @@ -0,0 +1,21 @@ +//using System; +//using System.Collections.Generic; + +//namespace Ch09 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List +// { +// 1,2,3,4,4,6,7,8,9,10 +// }; + +// foreach (int number in numbers) +// { +// Console.Write("{0}\t", number); +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch09/Listing 9-3.cs b/9781430248606_sourcecode/Ch09/Listing 9-3.cs new file mode 100644 index 0000000..bd85842 --- /dev/null +++ b/9781430248606_sourcecode/Ch09/Listing 9-3.cs @@ -0,0 +1,34 @@ +//using System; +//using System.Collections; + +//namespace Ch09 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int currentExponent = 0; +// int iterationPhase = 0; +// Console.WriteLine("{0,10}\t{1,10}\t{2,10}", +// "Iteration Phase", "Power", "Next Power will be"); +// foreach (int i in Power(2, 4)) +// { +// currentExponent = i; +// Console.Write("{0,9}\t{1,9}", +// ++iterationPhase, currentExponent); +// } +// } + +// public static IEnumerable Power(int number, int exponent) +// { +// int counter = 0; +// int result = 1; +// while (counter++ < exponent) +// { +// result = result * number; +// yield return result; +// Console.WriteLine("\t{0,9}x{1}\t\u25BC", result, number); +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch09/Program.cs b/9781430248606_sourcecode/Ch09/Program.cs new file mode 100644 index 0000000..309c0fa --- /dev/null +++ b/9781430248606_sourcecode/Ch09/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace Ch09 +{ + class Program + { + static void Main(string[] args) + { + IList numbers = new List + { + 1,2,3,4,4,6,7,8,9,10 + }; + + foreach (int number in numbers) + { + Console.Write("{0}\t", number); + } + } + } +} diff --git a/9781430248606_sourcecode/Ch09/Properties/AssemblyInfo.cs b/9781430248606_sourcecode/Ch09/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..546f36d --- /dev/null +++ b/9781430248606_sourcecode/Ch09/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ch09")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ch09")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b5b17faa-9286-49be-8a5d-34052dda628f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9781430248606_sourcecode/Ch09/app.config b/9781430248606_sourcecode/Ch09/app.config new file mode 100644 index 0000000..c5e1dae --- /dev/null +++ b/9781430248606_sourcecode/Ch09/app.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch09/bin/Debug/Ch09.vshost.exe b/9781430248606_sourcecode/Ch09/bin/Debug/Ch09.vshost.exe new file mode 100644 index 0000000..212bd7f Binary files /dev/null and b/9781430248606_sourcecode/Ch09/bin/Debug/Ch09.vshost.exe differ diff --git a/9781430248606_sourcecode/Ch09/bin/Debug/Ch09.vshost.exe.config b/9781430248606_sourcecode/Ch09/bin/Debug/Ch09.vshost.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch09/bin/Debug/Ch09.vshost.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch09/bin/Debug/Ch09.vshost.exe.manifest b/9781430248606_sourcecode/Ch09/bin/Debug/Ch09.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/9781430248606_sourcecode/Ch09/bin/Debug/Ch09.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/9781430248606_sourcecode/Ch09/bin/Release/Ch09.exe b/9781430248606_sourcecode/Ch09/bin/Release/Ch09.exe new file mode 100644 index 0000000..a6b5987 Binary files /dev/null and b/9781430248606_sourcecode/Ch09/bin/Release/Ch09.exe differ diff --git a/9781430248606_sourcecode/Ch09/bin/Release/Ch09.exe.config b/9781430248606_sourcecode/Ch09/bin/Release/Ch09.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch09/bin/Release/Ch09.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch09/bin/Release/Ch09.pdb b/9781430248606_sourcecode/Ch09/bin/Release/Ch09.pdb new file mode 100644 index 0000000..a30cc65 Binary files /dev/null and b/9781430248606_sourcecode/Ch09/bin/Release/Ch09.pdb differ diff --git a/9781430248606_sourcecode/Ch09/obj/x86/Debug/Ch09.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch09/obj/x86/Debug/Ch09.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..3660a5a --- /dev/null +++ b/9781430248606_sourcecode/Ch09/obj/x86/Debug/Ch09.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch09\bin\Debug\Ch09.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch09\bin\Debug\Ch09.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch09\bin\Debug\Ch09.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch09\obj\x86\Debug\Ch09.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch09\obj\x86\Debug\Ch09.pdb diff --git a/9781430248606_sourcecode/Ch09/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch09/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..14c02fa Binary files /dev/null and b/9781430248606_sourcecode/Ch09/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch09/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/9781430248606_sourcecode/Ch09/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch09/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/9781430248606_sourcecode/Ch09/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch09/obj/x86/Release/Ch09.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch09/obj/x86/Release/Ch09.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..24c602e --- /dev/null +++ b/9781430248606_sourcecode/Ch09/obj/x86/Release/Ch09.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch09\bin\Release\Ch09.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch09\bin\Release\Ch09.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch09\bin\Release\Ch09.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch09\obj\x86\Release\ResolveAssemblyReference.cache +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch09\obj\x86\Release\Ch09.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch09\obj\x86\Release\Ch09.pdb diff --git a/9781430248606_sourcecode/Ch09/obj/x86/Release/Ch09.exe b/9781430248606_sourcecode/Ch09/obj/x86/Release/Ch09.exe new file mode 100644 index 0000000..a6b5987 Binary files /dev/null and b/9781430248606_sourcecode/Ch09/obj/x86/Release/Ch09.exe differ diff --git a/9781430248606_sourcecode/Ch09/obj/x86/Release/Ch09.pdb b/9781430248606_sourcecode/Ch09/obj/x86/Release/Ch09.pdb new file mode 100644 index 0000000..a30cc65 Binary files /dev/null and b/9781430248606_sourcecode/Ch09/obj/x86/Release/Ch09.pdb differ diff --git a/9781430248606_sourcecode/Ch09/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch09/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..e4aef6f Binary files /dev/null and b/9781430248606_sourcecode/Ch09/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch10/Ch10.csproj b/9781430248606_sourcecode/Ch10/Ch10.csproj new file mode 100644 index 0000000..2647d2c --- /dev/null +++ b/9781430248606_sourcecode/Ch10/Ch10.csproj @@ -0,0 +1,76 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {0B6F3810-D7CB-497A-923B-D38CF61EAD44} + Exe + Properties + Ch10 + Ch10 + v4.5 + + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch10/Listing 10-10.cs b/9781430248606_sourcecode/Ch10/Listing 10-10.cs new file mode 100644 index 0000000..b9aae83 --- /dev/null +++ b/9781430248606_sourcecode/Ch10/Listing 10-10.cs @@ -0,0 +1,14 @@ +//using System; + +//namespace Ch10 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// string myString = " Expert C# 5.0: with the .NET 4.5 Framework by Mohammad A Rahman "; +// myString = myString.ToUpper().ToLower().Trim(); +// Console.WriteLine(myString); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch10/Listing 10-11.cs b/9781430248606_sourcecode/Ch10/Listing 10-11.cs new file mode 100644 index 0000000..b2c8a51 --- /dev/null +++ b/9781430248606_sourcecode/Ch10/Listing 10-11.cs @@ -0,0 +1,23 @@ +//using System; + +//namespace Ch10 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Console.WriteLine(ConcatUsingOperator()); +// Console.WriteLine(ConcatUsingOperator("One,", "Two,", "Three")); +// } + +// static string ConcatUsingOperator() +// { +// return "One," + "Two," + "Three."; +// } + +// static string ConcatUsingOperator(string one, string two, string three) +// { +// return one + two + three; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch10/Listing 10-14.cs b/9781430248606_sourcecode/Ch10/Listing 10-14.cs new file mode 100644 index 0000000..fda7ade --- /dev/null +++ b/9781430248606_sourcecode/Ch10/Listing 10-14.cs @@ -0,0 +1,23 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; + +//namespace Ch10 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList listOfNumbers = new List() +// { +// "One,", "Two,", "Three." +// }; +// Console.WriteLine("{0}", ConcateUsingConcate(listOfNumbers)); +// } + +// static string ConcateUsingConcate(IEnumerable enumerable) +// { +// return string.Concat(enumerable); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch10/Listing 10-16.cs b/9781430248606_sourcecode/Ch10/Listing 10-16.cs new file mode 100644 index 0000000..2c27c7e --- /dev/null +++ b/9781430248606_sourcecode/Ch10/Listing 10-16.cs @@ -0,0 +1,20 @@ +//using System; + +//namespace Ch10 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Console.WriteLine("{0}", ConcatUsingConcat(new[] +// { +// "One,", "Two,", "Three." +// })); +// } + +// static string ConcatUsingConcat(params object[] args) +// { +// return string.Concat(args); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch10/Listing 10-19.cs b/9781430248606_sourcecode/Ch10/Listing 10-19.cs new file mode 100644 index 0000000..a1170d7 --- /dev/null +++ b/9781430248606_sourcecode/Ch10/Listing 10-19.cs @@ -0,0 +1,18 @@ +//using System; + +//namespace Ch10 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Console.WriteLine("{0}", +// ConcatUsingConcat("Expert C# 5.0: with the .NET 4.5 Framework ", " by Mohammad Rahman")); +// } + +// static string ConcatUsingConcat(object args0, object args1) +// { +// return string.Concat(args0, args1); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch10/Listing 10-2.cs b/9781430248606_sourcecode/Ch10/Listing 10-2.cs new file mode 100644 index 0000000..8de79a3 --- /dev/null +++ b/9781430248606_sourcecode/Ch10/Listing 10-2.cs @@ -0,0 +1,27 @@ +//using System; +//using System.Text; +//namespace Ch10 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// string bookName = "Expert C# 5.0: with the .NET 4.5 Framework"; +// /* CLR will create a String with - by repeating the number +// * of the Length of the bookName string .*/ +// string dashedLine = new string('-', bookName.Length); +// StringBuilder sb = new StringBuilder("by Mohammad Rahman"); + +// Console.WriteLine("{0}\n{1}\n{2}", +// bookName, /* C# Compiler include the String Literal +// * used in bookName in metadata */ +// dashedLine, /* C# Compiler does not include the +// * String Literal used in dashedLine +// * in metadata */ +// sb.ToString()); /* C# Compiler include the String Literal +// * used in the constructor in metadata and +// * will construct the String at runtime +// * using StringBuilder */ +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch10/Listing 10-21.cs b/9781430248606_sourcecode/Ch10/Listing 10-21.cs new file mode 100644 index 0000000..4a15e4b --- /dev/null +++ b/9781430248606_sourcecode/Ch10/Listing 10-21.cs @@ -0,0 +1,18 @@ +//using System; + +//namespace Ch10 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Console.WriteLine("{0}", +// ConcatUsingConcat("Expert C# 5.0: with the .NET 4.5 Framework ", " by Mohammad Rahman")); +// } + +// static string ConcatUsingConcat(string str0, string str1) +// { +// return string.Concat(str0, str1); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch10/Listing 10-23.cs b/9781430248606_sourcecode/Ch10/Listing 10-23.cs new file mode 100644 index 0000000..2900803 --- /dev/null +++ b/9781430248606_sourcecode/Ch10/Listing 10-23.cs @@ -0,0 +1,16 @@ +//using System; +//using System.Text; + +//namespace Ch10 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// StringBuilder sb = new StringBuilder(); +// sb.Append("Expert C# 5.0: with the .NET 4.5 Framework "); +// sb.Insert(sb.Length, "by Mohammad A Rahman"); +// Console.WriteLine(sb.ToString()); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch10/Listing 10-28.cs b/9781430248606_sourcecode/Ch10/Listing 10-28.cs new file mode 100644 index 0000000..fca1bc2 --- /dev/null +++ b/9781430248606_sourcecode/Ch10/Listing 10-28.cs @@ -0,0 +1,69 @@ +//using System; +//using System.Text; + +//namespace Ch10 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Console.WriteLine("{0}", ConcatUsingStringBuilder( +// "Expert C# 5.0: with the .NET 4.5 Framework ", +// "by Mohammad Rahman")); +// Console.WriteLine("{0}", ConcatUsingStringBuilder()); +// } + +// static string ConcatUsingStringBuilder(string str0, string str1) +// { +// StringBuilder builder = new StringBuilder(); +// builder.Append(str0).Append("\t"); +// builder.Append(str1).Append("\t"); +// return builder.ToString(); +// } + +// static string ConcatUsingStringBuilder() +// { +// StringBuilder builder = new StringBuilder(); + +// bool boolValue = true; +// byte byteValue = 1; +// char charValue = 'A'; +// decimal decimalValue = 10; +// double doubleValue = 100; +// short shortValue = 1000; +// char[] charArrayValue = new char[] { 'A', 'B', 'C' }; +// int intValue = 10000; +// long longValue = 100000; +// object objectValue = new object(); +// sbyte sByteValue = 2; +// float floatValue = 200; +// string stringValue = "Expert C# 5.0: with the .NET 4.5 Framework"; +// ushort ushortValue = 10; +// uint uintValue = 4; +// ulong ulongValue = 400; + +// builder +// .Append(boolValue).Append("\t") +// .Append(byteValue).Append("\t") +// .Append(charValue).Append("\t") +// .Append(decimalValue).Append("\t") +// .Append(doubleValue).Append("\t") +// .Append(shortValue).Append("\t") +// .Append(charArrayValue).Append("\t") +// .Append(intValue).Append("\t") +// .Append(longValue).Append("\t") +// .Append(objectValue).Append("\t") +// .Append(sByteValue).Append("\t") +// .Append(floatValue).Append("\t") +// .Append(stringValue).Append("\t") +// .Append(ushortValue).Append("\t") +// .Append(uintValue).Append("\t") +// .Append(ulongValue).Append("\t") +// .Append(charValue, 10).Append("\t") +// .Append(stringValue, 1, 2).Append("\t") +// .Append(charArrayValue, 1, 2); + +// return builder.ToString(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch10/Listing 10-3.cs b/9781430248606_sourcecode/Ch10/Listing 10-3.cs new file mode 100644 index 0000000..07b8a91 --- /dev/null +++ b/9781430248606_sourcecode/Ch10/Listing 10-3.cs @@ -0,0 +1,14 @@ +//using System; + +//namespace Ch10 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// string book = LoadStringLiteral(); +// } +// static string LoadStringLiteral() +// { return "Expert C# 5.0: with the .NET 4.5 Framework"; } +// } +//} diff --git a/9781430248606_sourcecode/Ch10/Listing 10-5.cs b/9781430248606_sourcecode/Ch10/Listing 10-5.cs new file mode 100644 index 0000000..21cc4e1 --- /dev/null +++ b/9781430248606_sourcecode/Ch10/Listing 10-5.cs @@ -0,0 +1,19 @@ +//using System; +//namespace Ch10 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// string book = new String(new char[] +// { +// 'E', 'x', 'p', 'e', 'r', 't', ' ', 'C', '#', +// ' ', '5', '.', '0', ':', ' ', 'w', 'i', 't', +// 'h', ' ', 't', 'h', 'e', ' ', '.', 'N', 'E', +// 'T', ' ', '4', '.', '5', ' ', 'F', 'r', 'a', +// 'm', 'e', 'w', 'o', 'r', 'k' +// }); +// Console.WriteLine(book); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch10/Listing 10-7.cs b/9781430248606_sourcecode/Ch10/Listing 10-7.cs new file mode 100644 index 0000000..a2c6853 --- /dev/null +++ b/9781430248606_sourcecode/Ch10/Listing 10-7.cs @@ -0,0 +1,39 @@ +//using System; + +//namespace Ch10 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Book book = new Book(); +// Console.WriteLine( +// book. +// SetBookName("Expert C# 5.0: with the .NET 4.5 Framework"). +// SetPublishedYear(2012).ToString()); +// } +// } + +// public class Book +// { +// private string bookName = default(string); +// private Int32 publishedYear = default(int); + +// public Book SetBookName(string nameOfTheBook) +// { +// bookName = nameOfTheBook; +// return this; +// } + +// public Book SetPublishedYear(int yearOfThePublication) +// { +// publishedYear = yearOfThePublication; +// return this; +// } + +// public override string ToString() +// { +// return string.Format("{0}:{1}", bookName, publishedYear); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch10/Listing 10-8.cs b/9781430248606_sourcecode/Ch10/Listing 10-8.cs new file mode 100644 index 0000000..61c26b7 --- /dev/null +++ b/9781430248606_sourcecode/Ch10/Listing 10-8.cs @@ -0,0 +1,18 @@ +//using System; + +//namespace Ch10 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// string bookName = "A book name."; + +// /* replace the whole string */ +// bookName = "Expert C# 5.0: with the .NET 4.5 Framework"; + +// /* Compiler will generate error in here. */ +// bookName[2] = 'A'; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch10/Program.cs b/9781430248606_sourcecode/Ch10/Program.cs new file mode 100644 index 0000000..20efb54 --- /dev/null +++ b/9781430248606_sourcecode/Ch10/Program.cs @@ -0,0 +1,12 @@ +namespace Ch10 +{ + class Program + { + static void Main(string[] args) + { + string book = LoadStringLiteral(); + } + static string LoadStringLiteral() + { return "Expert C# 5.0: with the .NET 4.5 Framework"; } + } +} \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch10/Properties/AssemblyInfo.cs b/9781430248606_sourcecode/Ch10/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..eb531cd --- /dev/null +++ b/9781430248606_sourcecode/Ch10/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ch10")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ch10")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0fae1e5f-fa0b-4fc9-a78b-35363c97b560")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9781430248606_sourcecode/Ch10/app.config b/9781430248606_sourcecode/Ch10/app.config new file mode 100644 index 0000000..c5e1dae --- /dev/null +++ b/9781430248606_sourcecode/Ch10/app.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch10/bin/Debug/Ch10.vshost.exe b/9781430248606_sourcecode/Ch10/bin/Debug/Ch10.vshost.exe new file mode 100644 index 0000000..bb84a51 Binary files /dev/null and b/9781430248606_sourcecode/Ch10/bin/Debug/Ch10.vshost.exe differ diff --git a/9781430248606_sourcecode/Ch10/bin/Debug/Ch10.vshost.exe.config b/9781430248606_sourcecode/Ch10/bin/Debug/Ch10.vshost.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch10/bin/Debug/Ch10.vshost.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch10/bin/Debug/Ch10.vshost.exe.manifest b/9781430248606_sourcecode/Ch10/bin/Debug/Ch10.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/9781430248606_sourcecode/Ch10/bin/Debug/Ch10.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/9781430248606_sourcecode/Ch10/bin/Release/Ch10.exe b/9781430248606_sourcecode/Ch10/bin/Release/Ch10.exe new file mode 100644 index 0000000..4d38c4f Binary files /dev/null and b/9781430248606_sourcecode/Ch10/bin/Release/Ch10.exe differ diff --git a/9781430248606_sourcecode/Ch10/bin/Release/Ch10.exe.config b/9781430248606_sourcecode/Ch10/bin/Release/Ch10.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch10/bin/Release/Ch10.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch10/bin/Release/Ch10.pdb b/9781430248606_sourcecode/Ch10/bin/Release/Ch10.pdb new file mode 100644 index 0000000..330ad43 Binary files /dev/null and b/9781430248606_sourcecode/Ch10/bin/Release/Ch10.pdb differ diff --git a/9781430248606_sourcecode/Ch10/obj/x86/Debug/Ch10.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch10/obj/x86/Debug/Ch10.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..860c8e6 --- /dev/null +++ b/9781430248606_sourcecode/Ch10/obj/x86/Debug/Ch10.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch10\bin\Debug\Ch10.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch10\bin\Debug\Ch10.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch10\bin\Debug\Ch10.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch10\obj\x86\Debug\Ch10.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch10\obj\x86\Debug\Ch10.pdb diff --git a/9781430248606_sourcecode/Ch10/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch10/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..fbeabac Binary files /dev/null and b/9781430248606_sourcecode/Ch10/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch10/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/9781430248606_sourcecode/Ch10/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch10/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/9781430248606_sourcecode/Ch10/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch10/obj/x86/Release/Ch10.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch10/obj/x86/Release/Ch10.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..0201db2 --- /dev/null +++ b/9781430248606_sourcecode/Ch10/obj/x86/Release/Ch10.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch10\bin\Release\Ch10.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch10\bin\Release\Ch10.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch10\bin\Release\Ch10.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch10\obj\x86\Release\ResolveAssemblyReference.cache +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch10\obj\x86\Release\Ch10.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch10\obj\x86\Release\Ch10.pdb diff --git a/9781430248606_sourcecode/Ch10/obj/x86/Release/Ch10.exe b/9781430248606_sourcecode/Ch10/obj/x86/Release/Ch10.exe new file mode 100644 index 0000000..4d38c4f Binary files /dev/null and b/9781430248606_sourcecode/Ch10/obj/x86/Release/Ch10.exe differ diff --git a/9781430248606_sourcecode/Ch10/obj/x86/Release/Ch10.pdb b/9781430248606_sourcecode/Ch10/obj/x86/Release/Ch10.pdb new file mode 100644 index 0000000..330ad43 Binary files /dev/null and b/9781430248606_sourcecode/Ch10/obj/x86/Release/Ch10.pdb differ diff --git a/9781430248606_sourcecode/Ch10/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch10/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..20d1463 Binary files /dev/null and b/9781430248606_sourcecode/Ch10/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch11/Ch11.csproj b/9781430248606_sourcecode/Ch11/Ch11.csproj new file mode 100644 index 0000000..d2929da --- /dev/null +++ b/9781430248606_sourcecode/Ch11/Ch11.csproj @@ -0,0 +1,72 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {3E8C37A0-B67E-4B8D-8463-0E27AE5CC063} + Exe + Properties + Ch11 + Ch11 + v4.5 + + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch11/Listing 11-1.cs b/9781430248606_sourcecode/Ch11/Listing 11-1.cs new file mode 100644 index 0000000..1175e37 --- /dev/null +++ b/9781430248606_sourcecode/Ch11/Listing 11-1.cs @@ -0,0 +1,23 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; + +//namespace Ch11 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// List numbers = new List(); +// numbers.Add(0); +// numbers.Add(1); +// ShowResult(numbers); +// } +// public static void ShowResult(IEnumerable aList) +// { +// foreach (var item in aList) +// Console.Write("{0}\t", item); +// Console.WriteLine(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch11/Listing 11-10.cs b/9781430248606_sourcecode/Ch11/Listing 11-10.cs new file mode 100644 index 0000000..283074b --- /dev/null +++ b/9781430248606_sourcecode/Ch11/Listing 11-10.cs @@ -0,0 +1,26 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; + +//namespace Ch11 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// ArrayList numbers = new ArrayList() +// { +// 0,1, 2, 3 +// }; +// numbers.InsertRange(3, new List() { 22, 33, 77 }); +// ShowResult(numbers); +// } + +// public static void ShowResult(IEnumerable aList) +// { +// foreach (var item in aList) +// Console.Write("{0}\t", item); +// Console.WriteLine(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch11/Listing 11-11.cs b/9781430248606_sourcecode/Ch11/Listing 11-11.cs new file mode 100644 index 0000000..04df3bf --- /dev/null +++ b/9781430248606_sourcecode/Ch11/Listing 11-11.cs @@ -0,0 +1,27 @@ +//using System; +//using System.Collections; + +//namespace Ch11 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// ArrayList terrestrialPlanets = new ArrayList(); +// terrestrialPlanets.Add("Mercury"); +// terrestrialPlanets.Add("Venus"); +// terrestrialPlanets.Add("Earth"); +// terrestrialPlanets.Add("Mars"); + +// terrestrialPlanets.Remove("Venus"); +// ShowResult(terrestrialPlanets); +// } + +// public static void ShowResult(IEnumerable aList) +// { +// foreach (string item in aList) +// Console.Write("{0}\t", item); +// Console.WriteLine(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch11/Listing 11-13.cs b/9781430248606_sourcecode/Ch11/Listing 11-13.cs new file mode 100644 index 0000000..0409295 --- /dev/null +++ b/9781430248606_sourcecode/Ch11/Listing 11-13.cs @@ -0,0 +1,26 @@ +//using System; +//using System.Collections; + +//namespace Ch11 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Stack terrestrialPlanets = new Stack(); +// terrestrialPlanets.Push("Mercury"); +// terrestrialPlanets.Push("Venus"); +// terrestrialPlanets.Push("Earth"); +// terrestrialPlanets.Push("Mars"); + +// ShowResult(terrestrialPlanets); +// } + +// public static void ShowResult(IEnumerable aList) +// { +// foreach (string item in aList) +// Console.Write("{0}\t", item); +// Console.WriteLine(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch11/Listing 11-20.cs b/9781430248606_sourcecode/Ch11/Listing 11-20.cs new file mode 100644 index 0000000..dfabfb1 --- /dev/null +++ b/9781430248606_sourcecode/Ch11/Listing 11-20.cs @@ -0,0 +1,25 @@ +//using System; +//using System.Collections; + +//namespace Ch11 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Queue terrestrialPlanets = new Queue(); +// terrestrialPlanets.Enqueue("Mercury"); +// terrestrialPlanets.Enqueue("Venus"); +// terrestrialPlanets.Enqueue("Earth"); +// terrestrialPlanets.Enqueue("Mars"); +// ShowResult(terrestrialPlanets); +// } + +// public static void ShowResult(IEnumerable aList) +// { +// foreach (string item in aList) +// Console.Write("{0}\t", item); +// Console.WriteLine(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch11/Listing 11-25.cs b/9781430248606_sourcecode/Ch11/Listing 11-25.cs new file mode 100644 index 0000000..77cfb0d --- /dev/null +++ b/9781430248606_sourcecode/Ch11/Listing 11-25.cs @@ -0,0 +1,31 @@ +//using System; +//using System.Collections; + +//namespace Ch11 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Hashtable terrestrialPlanets = new Hashtable(); +// terrestrialPlanets.Add("Mercury", +// "The innermost of the eight planets."); +// terrestrialPlanets.Add("Venus", +// "The second planet from the Sun."); +// terrestrialPlanets.Add("Earth", +// "The third planet from the Sun."); +// terrestrialPlanets.Add("Mars", +// "The fourth planet from the Sun."); +// terrestrialPlanets.Add("Vesta", +// "One of the largest asteroids in the Solar System."); + +// Console.WriteLine( +// "Mercury\t{0}\nVenus\t{1}\nEarth\t{2}\nMars\t{3}\nVesta\t{4}", +// terrestrialPlanets["Mercury"], +// terrestrialPlanets["Venus"], +// terrestrialPlanets["Earth"], +// terrestrialPlanets["Mars"], +// terrestrialPlanets["Vesta"]); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch11/Listing 11-27.cs b/9781430248606_sourcecode/Ch11/Listing 11-27.cs new file mode 100644 index 0000000..8e3524b --- /dev/null +++ b/9781430248606_sourcecode/Ch11/Listing 11-27.cs @@ -0,0 +1,38 @@ +//using System; +//using System.Collections.Generic; + +//namespace Ch11 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IDictionary terrestrialPlanets = +// new Dictionary(); + +// terrestrialPlanets.Add("Mercury", +// "The innermost of the eight planets."); +// terrestrialPlanets.Add("Venus", +// "The second planet from the Sun."); +// terrestrialPlanets.Add("Earth", +// "The third planet from the Sun."); +// terrestrialPlanets.Add("Mars", +// "The fourth planet from the Sun."); +// terrestrialPlanets.Add("Vesta", +// "One of the largest asteroids in the Solar System."); +// terrestrialPlanets.Add("Ceres", +// "The dwarf planet in the inner Solar System."); +// terrestrialPlanets.Add("Pallas", +// "One of the largest in the Solar System."); + +// Console.WriteLine("Mercury\t{0}\nVenus\t{1}\nEarth\t{2}\nMars\t{3}\nVesta\t{4}\nCeres\t{5}\nPallas\t{6}\n", +// terrestrialPlanets["Mercury"], +// terrestrialPlanets["Venus"], +// terrestrialPlanets["Earth"], +// terrestrialPlanets["Mars"], +// terrestrialPlanets["Vesta"], +// terrestrialPlanets["Ceres"], +// terrestrialPlanets["Pallas"]); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch11/Listing 11-4.cs b/9781430248606_sourcecode/Ch11/Listing 11-4.cs new file mode 100644 index 0000000..948c533 --- /dev/null +++ b/9781430248606_sourcecode/Ch11/Listing 11-4.cs @@ -0,0 +1,26 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; + +//namespace Ch11 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// List numbers = new List() +// { +// 0,1, 2, 3 +// }; +// numbers.InsertRange(3, new List() { 22, 33, 77 }); +// ShowResult(numbers); +// } + +// public static void ShowResult(IEnumerable aList) +// { +// foreach (var item in aList) +// Console.Write("{0}\t", item); +// Console.WriteLine(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch11/Listing 11-6.cs b/9781430248606_sourcecode/Ch11/Listing 11-6.cs new file mode 100644 index 0000000..1c9b607 --- /dev/null +++ b/9781430248606_sourcecode/Ch11/Listing 11-6.cs @@ -0,0 +1,27 @@ +//using System; +//using System.Collections; + +//namespace Ch11 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// ArrayList terrestrialPlanets = new ArrayList(); +// terrestrialPlanets.Add("Mercury"); /* Default capacity is 4.*/ +// terrestrialPlanets.Add("Venus"); +// terrestrialPlanets.Add("Earth"); +// terrestrialPlanets.Add("Mars"); + +// ShowResult(terrestrialPlanets); +// } + +// public static void ShowResult( +// IEnumerable aList, char mySeparator = ' ') +// { +// foreach (string item in aList) +// Console.Write("{0}{1}", mySeparator, item); +// Console.WriteLine(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch11/Program.cs b/9781430248606_sourcecode/Ch11/Program.cs new file mode 100644 index 0000000..0db5cfc --- /dev/null +++ b/9781430248606_sourcecode/Ch11/Program.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Ch12 +{ + class Program + { + static void Main(string[] args) + { + IList firstList = new List() + { + 1,2,3,4 + }; + + IList secondList = new List() + { + "One","Two","Three","Four" + }; + + var result = firstList.Zip(secondList, (x, y) => x + ":\t" + y); + + result.ToList().ForEach(x => Console.WriteLine(x)); + } + + + + } +} diff --git a/9781430248606_sourcecode/Ch11/Properties/AssemblyInfo.cs b/9781430248606_sourcecode/Ch11/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6adf6d3 --- /dev/null +++ b/9781430248606_sourcecode/Ch11/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ch11")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ch11")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("07b8343f-7382-4e0e-ab3a-1964ad3fbede")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9781430248606_sourcecode/Ch11/app.config b/9781430248606_sourcecode/Ch11/app.config new file mode 100644 index 0000000..c5e1dae --- /dev/null +++ b/9781430248606_sourcecode/Ch11/app.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch11/bin/Debug/Ch11.vshost.exe b/9781430248606_sourcecode/Ch11/bin/Debug/Ch11.vshost.exe new file mode 100644 index 0000000..212bd7f Binary files /dev/null and b/9781430248606_sourcecode/Ch11/bin/Debug/Ch11.vshost.exe differ diff --git a/9781430248606_sourcecode/Ch11/bin/Debug/Ch11.vshost.exe.config b/9781430248606_sourcecode/Ch11/bin/Debug/Ch11.vshost.exe.config new file mode 100644 index 0000000..c5e1dae --- /dev/null +++ b/9781430248606_sourcecode/Ch11/bin/Debug/Ch11.vshost.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch11/bin/Debug/Ch11.vshost.exe.manifest b/9781430248606_sourcecode/Ch11/bin/Debug/Ch11.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/9781430248606_sourcecode/Ch11/bin/Debug/Ch11.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/9781430248606_sourcecode/Ch11/bin/Release/Ch11.exe b/9781430248606_sourcecode/Ch11/bin/Release/Ch11.exe new file mode 100644 index 0000000..0ec9453 Binary files /dev/null and b/9781430248606_sourcecode/Ch11/bin/Release/Ch11.exe differ diff --git a/9781430248606_sourcecode/Ch11/bin/Release/Ch11.exe.config b/9781430248606_sourcecode/Ch11/bin/Release/Ch11.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch11/bin/Release/Ch11.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch11/bin/Release/Ch11.pdb b/9781430248606_sourcecode/Ch11/bin/Release/Ch11.pdb new file mode 100644 index 0000000..7be4ebf Binary files /dev/null and b/9781430248606_sourcecode/Ch11/bin/Release/Ch11.pdb differ diff --git a/9781430248606_sourcecode/Ch11/obj/x86/Debug/Ch11.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch11/obj/x86/Debug/Ch11.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..648f765 --- /dev/null +++ b/9781430248606_sourcecode/Ch11/obj/x86/Debug/Ch11.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch11\bin\Debug\Ch11.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch11\bin\Debug\Ch11.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch11\bin\Debug\Ch11.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch11\obj\x86\Debug\Ch11.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch11\obj\x86\Debug\Ch11.pdb diff --git a/9781430248606_sourcecode/Ch11/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch11/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..748df93 Binary files /dev/null and b/9781430248606_sourcecode/Ch11/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch11/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/9781430248606_sourcecode/Ch11/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch11/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/9781430248606_sourcecode/Ch11/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch11/obj/x86/Release/Ch11.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch11/obj/x86/Release/Ch11.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..398eef0 --- /dev/null +++ b/9781430248606_sourcecode/Ch11/obj/x86/Release/Ch11.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch11\bin\Release\Ch11.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch11\bin\Release\Ch11.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch11\bin\Release\Ch11.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch11\obj\x86\Release\ResolveAssemblyReference.cache +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch11\obj\x86\Release\Ch11.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch11\obj\x86\Release\Ch11.pdb diff --git a/9781430248606_sourcecode/Ch11/obj/x86/Release/Ch11.exe b/9781430248606_sourcecode/Ch11/obj/x86/Release/Ch11.exe new file mode 100644 index 0000000..0ec9453 Binary files /dev/null and b/9781430248606_sourcecode/Ch11/obj/x86/Release/Ch11.exe differ diff --git a/9781430248606_sourcecode/Ch11/obj/x86/Release/Ch11.pdb b/9781430248606_sourcecode/Ch11/obj/x86/Release/Ch11.pdb new file mode 100644 index 0000000..7be4ebf Binary files /dev/null and b/9781430248606_sourcecode/Ch11/obj/x86/Release/Ch11.pdb differ diff --git a/9781430248606_sourcecode/Ch11/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch11/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..c8a41fc Binary files /dev/null and b/9781430248606_sourcecode/Ch11/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch12/Ch12.csproj b/9781430248606_sourcecode/Ch12/Ch12.csproj new file mode 100644 index 0000000..4830487 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Ch12.csproj @@ -0,0 +1,110 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {AECCD015-05F0-47E3-973F-156EB64C956A} + Exe + Properties + Ch12 + Ch12 + v4.5 + + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + false + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch12/Listing 12-1.cs b/9781430248606_sourcecode/Ch12/Listing 12-1.cs new file mode 100644 index 0000000..852870c --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-1.cs @@ -0,0 +1,23 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List() +// { +// "One", "Two", "Three", "Four", "Five", "Six", "Seven" +// }; + +// var numbersLengthThree = +// numbers.Where(x => x.Length == 3).Select(x => x).ToList(); + +// numbersLengthThree.ForEach(x => Console.WriteLine(x)); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-10.cs b/9781430248606_sourcecode/Ch12/Listing 12-10.cs new file mode 100644 index 0000000..20c06cd --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-10.cs @@ -0,0 +1,29 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Text; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList series = new List() +// { +// 1,2,3,4,5,6,7 +// }; +// Console.WriteLine("When the condition is true"); +// series.TakeWhile(number => number < 3) +// .ToList() +// .ForEach(number => Console.Write(string.Format("{0}\t", +// number))); + +// Console.WriteLine("\nOn first false return iteration will stop "); +// series.TakeWhile(number => number > 3) +// .ToList() +// .ForEach(number => Console.Write(string.Format("{0}\t", +// number))); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-11.cs b/9781430248606_sourcecode/Ch12/Listing 12-11.cs new file mode 100644 index 0000000..4afbf1c --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-11.cs @@ -0,0 +1,26 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList listOne = new List() +// { +// 1,2,3,4,5,6 +// }; + +// IList listTwo = new List() +// { +// 6,7,8,9,10 +// }; + +// var result = listOne.Concat(listTwo).ToList(); +// result.ForEach(x => Console.Write(string.Format("{0}\t", x))); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-12.cs b/9781430248606_sourcecode/Ch12/Listing 12-12.cs new file mode 100644 index 0000000..64aa8f5 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-12.cs @@ -0,0 +1,63 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList persons = new List() +// { +// new Person(){ Name="Person F", Address= "Address of F", +// Id= 111116}, +// new Person(){ Name="Person G", Address= "Address of G", +// Id= 111117}, +// new Person(){ Name="Person C", Address= "Address of C", +// Id= 111113}, +// new Person(){ Name="Person B", Address= "Address of B", +// Id= 111112}, +// new Person(){ Name="Person D", Address= "Address of D", +// Id= 111114}, +// new Person(){ Name="Person A", Address= "Address of A", +// Id= 111111}, +// new Person(){ Name="Person E", Address= "Address of E", +// Id= 111115} +// }; + +// var result = +// persons.OrderBy(person => person.Id).ThenBy(person => person); + +// foreach (Person person in result) +// { +// Console.WriteLine("{0,-15} {1,-20}{2,-20}", +// person.Name, +// person.Address, +// person.Id); +// } +// } +// } + +// public class Person +// { +// public string Name +// { +// get; +// set; +// } + +// public string Address +// { +// get; +// set; +// } + +// public double Id +// { +// get; +// set; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-16.cs b/9781430248606_sourcecode/Ch12/Listing 12-16.cs new file mode 100644 index 0000000..9e84da8 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-16.cs @@ -0,0 +1,20 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List() { 1, 2, 3, 4, 5 }; +// var reverseNumbers = numbers.Reverse(); + +// var result = reverseNumbers.ToList(); + +// result.ForEach(x => Console.Write("{0}\t", x)); +// Console.WriteLine(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-18.cs b/9781430248606_sourcecode/Ch12/Listing 12-18.cs new file mode 100644 index 0000000..1f29ded --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-18.cs @@ -0,0 +1,71 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// List persons; +// List
addresses; + +// InitializeData(out persons, out addresses); + +// /* persons - Outer Sequence */ +// var result = persons.Join( +// /*addresses - Inner Sequence*/ +// addresses, +// /* Outer Key Selector */ +// person => person, +// /* Inner Key Selector */ +// address => address.AddressOf, +// /* Result Selector */ +// (person, address) => +// new +// { +// PersonName = person.PersonName, +// AddressDetails = address.AddressDetails +// } +// ); + +// result.ToList(). +// ForEach(personAddress => +// Console.WriteLine("{0} \t{1}", +// personAddress.PersonName, personAddress.AddressDetails)); +// } + +// private static void InitializeData( +// out List persons, out List
addresses) +// { +// var personA = new Person { PersonID = "PA_01", PersonName = "A" }; +// var personB = new Person { PersonID = "PB_01", PersonName = "B" }; +// var personC = new Person { PersonID = "PC_01", PersonName = "C" }; + +// var addressOne = new Address +// { +// AddressOf = personA, +// AddressDetails = "Mystery Street,Jupiter" +// }; +// var addressTwo = new Address { AddressOf = personA, AddressDetails = "Dark Street,Mars" }; +// var addressThree = new Address { AddressOf = personB, AddressDetails = "Sun Street,Jupiter" }; +// var addressFour = new Address { AddressOf = personC, AddressDetails = "Dry Street,Neptune" }; + +// persons = new List { personA, personB, personC }; +// addresses = new List
{ addressOne, addressTwo, addressThree, addressFour }; +// } +// } + +// public class Person +// { +// public string PersonID { get; set; } +// public string PersonName { get; set; } +// } + +// public class Address +// { +// public Person AddressOf { get; set; } +// public string AddressDetails { get; set; } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-21.cs b/9781430248606_sourcecode/Ch12/Listing 12-21.cs new file mode 100644 index 0000000..55c087d --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-21.cs @@ -0,0 +1,70 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// List persons; +// List
addresses; +// InitializeData(out persons, out addresses); + +// /* persons - Outer Sequence */ +// var result = persons.GroupJoin( +// /*addresses - Inner Sequence*/ +// addresses, +// /* Outer Key Selector */ +// person => person, +// /* Inner Key Selector */ +// address => address.AddressOf, +// /* Result Selector */ +// (person, address) => +// new +// { +// PersonName = person.PersonName, +// AddressDetails = +// address.Select(innerAddress => innerAddress.AddressDetails) +// } +// ); + +// var rr = result.ToList(); +// foreach (var item in result) +// { +// Console.WriteLine("{0}", item.PersonName); +// item.AddressDetails.ToList().ForEach( +// address => Console.WriteLine(address)); +// } +// } + +// private static void InitializeData( +// out List persons, out List
addresses) +// { +// var personA = new Person { PersonID = "PA_01", PersonName = "A" }; +// var personB = new Person { PersonID = "PB_01", PersonName = "B" }; +// var personC = new Person { PersonID = "PC_01", PersonName = "C" }; + +// var addressOne = new Address { AddressOf = personA, AddressDetails = "Mystery Street,Jupiter" }; +// var addressTwo = new Address { AddressOf = personA, AddressDetails = "Dark Street,Mars" }; +// var addressThree = new Address { AddressOf = personB, AddressDetails = "Sun Street,Jupiter" }; +// var addressFour = new Address { AddressOf = personC, AddressDetails = "Dry Street,Neptune" }; + +// persons = new List { personA, personB, personC }; +// addresses = new List
{ addressOne, addressTwo, addressThree, addressFour }; +// } +// } + +// public class Person +// { +// public string PersonID { get; set; } +// public string PersonName { get; set; } +// } + +// public class Address +// { +// public Person AddressOf { get; set; } +// public string AddressDetails { get; set; } +// } +//} \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch12/Listing 12-22.cs b/9781430248606_sourcecode/Ch12/Listing 12-22.cs new file mode 100644 index 0000000..26fee2c --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-22.cs @@ -0,0 +1,57 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// List persons; +// InitializeData(out persons); + +// var result = persons.GroupBy( +// person => person.PersonAge, +// person => person.PersonID, +// (Age, Id) => +// new +// { +// PersonAge = Age, +// PersonID = Id +// } +// ); + +// Console.WriteLine("Age group \t No of person \t Persons are"); +// result.ToList().ForEach(item => +// Console.WriteLine( +// string.Format("{0,5} \t {1,15} \t {2,-33}", +// item.PersonAge, +// item.PersonID.Count(), +// string.Join(",", item.PersonID)))); +// } + +// private static void InitializeData( +// out List persons) +// { +// persons = new List +// { +// new Person { PersonID = "PA_01", PersonAge = 6 }, +// new Person { PersonID = "PB_01", PersonAge = 7 }, +// new Person { PersonID = "PC_01", PersonAge = 7 }, +// new Person { PersonID = "PD_01", PersonAge = 4 }, +// new Person { PersonID = "PE_01", PersonAge = 7 }, +// new Person { PersonID = "PF_01", PersonAge = 5 }, +// new Person { PersonID = "PG_01", PersonAge = 5 }, +// new Person { PersonID = "PH_01", PersonAge = 9 }, +// new Person { PersonID = "PI_01", PersonAge = 9 } +// }; +// } +// } + +// public class Person +// { +// public string PersonID { get; set; } +// public int PersonAge { get; set; } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-23.cs b/9781430248606_sourcecode/Ch12/Listing 12-23.cs new file mode 100644 index 0000000..46990d7 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-23.cs @@ -0,0 +1,21 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List() +// { +// 1,1,1,2,2,2,3,3,3 +// }; + +// var distinctedNumbers = numbers.Distinct().ToList(); +// distinctedNumbers.ForEach(x => Console.Write(string.Format("{0}\t", x))); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-25.cs b/9781430248606_sourcecode/Ch12/Listing 12-25.cs new file mode 100644 index 0000000..2baf406 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-25.cs @@ -0,0 +1,25 @@ +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; +//using System; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList firstNumbers = new List() +// { +// 1,2,3,4,5,6,7 +// }; +// IList secondNumbers = new List() +// { +// 1,2,3 +// }; + +// var result = firstNumbers.Except(secondNumbers).ToList(); +// result.ForEach(x => Console.Write(string.Format("{0}\t", x))); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-27.cs b/9781430248606_sourcecode/Ch12/Listing 12-27.cs new file mode 100644 index 0000000..7743ef6 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-27.cs @@ -0,0 +1,27 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList firstList = new List() +// { +// 1,2,3,4 +// }; + +// IList secondList = new List() +// { +// 7,9,3,4,5,6,7 +// }; + +// var result = firstList.Union(secondList); +// result.ToList().ForEach(x => +// Console.Write(string.Format("{0}\t", x))); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-29.cs b/9781430248606_sourcecode/Ch12/Listing 12-29.cs new file mode 100644 index 0000000..f858b4c --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-29.cs @@ -0,0 +1,19 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList listA = new List() { 1, 2, 3, 4, 5 }; +// IList listB = new List() { 4, 5 }; + +// var intersectResult = listA.Intersect(listB); + +// intersectResult.ToList().ForEach(x => Console.Write("{0}\t", x)); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-31.cs b/9781430248606_sourcecode/Ch12/Listing 12-31.cs new file mode 100644 index 0000000..15a56a5 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-31.cs @@ -0,0 +1,23 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List() +// { +// 1,2,3,4,5,6,7,8,9,10 +// }; + +// Console.WriteLine("Sum of the numbers :{0}", numbers.Sum()); + +// Console.WriteLine("Sum of the original numbers x 2 :{0}", +// numbers.Sum(x => x * 2)); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-32.cs b/9781430248606_sourcecode/Ch12/Listing 12-32.cs new file mode 100644 index 0000000..c854e0e --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-32.cs @@ -0,0 +1,20 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList firstList = new List() +// { +// 1,2,3,4 +// }; + +// Console.WriteLine(firstList.LongCount()); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-33.cs b/9781430248606_sourcecode/Ch12/Listing 12-33.cs new file mode 100644 index 0000000..6b8d072 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-33.cs @@ -0,0 +1,22 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List() +// { +// 1,2,3,4,5,6,7,8,9,10 +// }; + +// Console.WriteLine("Max of the numbers :{0}", numbers.Max()); +// Console.WriteLine("Max of the original numbers x2 :{0}", +// numbers.Max(x => x * 2)); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-34.cs b/9781430248606_sourcecode/Ch12/Listing 12-34.cs new file mode 100644 index 0000000..81c4bae --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-34.cs @@ -0,0 +1,23 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List() +// { +// 1,2,3,4,5,6,7,8,9,10 +// }; + +// Console.WriteLine("Min of the numbers :{0}", numbers.Min()); + +// Console.WriteLine("Min of the original numbers x2 :{0}", +// numbers.Min(x => x * 2)); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-35.cs b/9781430248606_sourcecode/Ch12/Listing 12-35.cs new file mode 100644 index 0000000..1d3c184 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-35.cs @@ -0,0 +1,23 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList listOne = new List() +// { +// "One","Two","Three" +// }; + +// var result = listOne.Count(); + +// var fourOrMoreCharacters = listOne.Count(item => item.Length > 3); +// Console.WriteLine("{0}\n{1}", result, fourOrMoreCharacters); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-37.cs b/9781430248606_sourcecode/Ch12/Listing 12-37.cs new file mode 100644 index 0000000..506886e --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-37.cs @@ -0,0 +1,23 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List() +// { +// 1,2,3,4,5,6,7,8,9,10 +// }; +// Console.WriteLine("Average of the numbers :{0}", +// numbers.Average()); + +// Console.WriteLine("Average of the original numbers x2 :{0}", +// numbers.Average((x => x * 2))); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-39.cs b/9781430248606_sourcecode/Ch12/Listing 12-39.cs new file mode 100644 index 0000000..b236d26 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-39.cs @@ -0,0 +1,24 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { + +// List numbers = new List() +// { +// "One", "Two", "Three", "Four" +// }; + +// var result = numbers.Aggregate( +// (aggregatedValue, nextItem) => +// nextItem + aggregatedValue); + +// Console.WriteLine("Aggregated value : {0}", result); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-41.cs b/9781430248606_sourcecode/Ch12/Listing 12-41.cs new file mode 100644 index 0000000..f08bfe1 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-41.cs @@ -0,0 +1,30 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// List items = new List() +// { +// "One", "Two", "Three", "Four" +// }; +// var result = items.Aggregate( +// /* Zero as seed, to use the initial aggregate value */ +// "Zero", +// (temporaryAggregatedValue, nextItem) => +// { +// Console.WriteLine(temporaryAggregatedValue); +// return nextItem + temporaryAggregatedValue; +// }, +// aggregatedResult => +// string.Format("Final result : {0}", +// aggregatedResult.ToUpper()) +// ); +// Console.WriteLine(result); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-43.cs b/9781430248606_sourcecode/Ch12/Listing 12-43.cs new file mode 100644 index 0000000..03f4c86 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-43.cs @@ -0,0 +1,22 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List() +// { +// "One", "Two", "Three", "Four", "Five", "Six", "Seven" +// }; + +// if (numbers.All(x => x.Length >= 3)) +// Console.WriteLine( +// "All numbers have at least three characters."); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-44.cs b/9781430248606_sourcecode/Ch12/Listing 12-44.cs new file mode 100644 index 0000000..e7a3ba8 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-44.cs @@ -0,0 +1,24 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List() +// { +// "One", "Two", "Three", "Four", "Five", "Six", "Seven" +// }; + +// if (numbers.Any()) +// Console.WriteLine("Contains"); + +// if (numbers.Any(x => x.Length >= 3)) +// Console.WriteLine("Contains"); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-47.cs b/9781430248606_sourcecode/Ch12/Listing 12-47.cs new file mode 100644 index 0000000..16f1b38 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-47.cs @@ -0,0 +1,21 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList listOne = new List() +// { +// 1,2,3,4,5 +// }; + +// var resultAsTrue = listOne.Contains(2); +// var resultAsFalse = listOne.Contains(200); +// Console.WriteLine("{0}\n{1}", resultAsTrue, resultAsFalse); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-49.cs b/9781430248606_sourcecode/Ch12/Listing 12-49.cs new file mode 100644 index 0000000..3804d5e --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-49.cs @@ -0,0 +1,25 @@ +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; +//using System; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List() +// { +// 1,2,3,4,5,6,7 +// }; + +// var firstItem = numbers.First(); +// var firstItemBasedOnConditions = numbers.First(item => item > 3); + +// Console.WriteLine("{0}\n{1}", +// firstItem, +// firstItemBasedOnConditions); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-5.cs b/9781430248606_sourcecode/Ch12/Listing 12-5.cs new file mode 100644 index 0000000..e0398c7 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-5.cs @@ -0,0 +1,21 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List() +// { +// "One","Two","Three", "Four","Five" +// }; + +// var result = numbers.Skip(2); +// result.ToList().ForEach(number => Console.WriteLine(number)); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-51.cs b/9781430248606_sourcecode/Ch12/Listing 12-51.cs new file mode 100644 index 0000000..a16dffe --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-51.cs @@ -0,0 +1,35 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList firstNumbers = new List(); + +// IList secondNumbers = new List() +// { +// 1,2,3,4,5,6,7 +// }; + +// var firstItemOfFirstList = firstNumbers.FirstOrDefault(); +// var firstItemIfFirstListBasedOnConditions = +// firstNumbers.FirstOrDefault(item => item > 3); + +// var firstItemOfSecondList = secondNumbers.FirstOrDefault(); +// var firstItemOfSecondListBasedOnConditions = +// secondNumbers.FirstOrDefault(item => item > 3); + +// Console.Write(string.Format("{0}\t{1}\t{2}\t{3}", +// firstItemOfFirstList, +// firstItemIfFirstListBasedOnConditions, +// firstItemOfSecondList, +// firstItemOfSecondListBasedOnConditions +// )); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-54.cs b/9781430248606_sourcecode/Ch12/Listing 12-54.cs new file mode 100644 index 0000000..4a7b9d8 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-54.cs @@ -0,0 +1,23 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List() +// { +// 1,2,3,4,5,6,7 +// }; + +// var lastItem = numbers.Last(); +// Console.WriteLine(lastItem); +// var lastItemBasedOnConditions = numbers.Last(item => item > 3); +// Console.WriteLine(lastItemBasedOnConditions); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-57.cs b/9781430248606_sourcecode/Ch12/Listing 12-57.cs new file mode 100644 index 0000000..9d17216 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-57.cs @@ -0,0 +1,35 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList firstNumbers = new List(); + +// IList secondNumbers = new List() +// { +// 1,2,3,4,5,6,7 +// }; + +// var lastItemOfFirstList = firstNumbers.LastOrDefault(); +// var lastItemIfFirstListBasedOnConditions = +// firstNumbers.LastOrDefault(item => item > 3); + +// var lastItemOfSecondList = secondNumbers.LastOrDefault(); +// var lastItemOfSecondListBasedOnConditions = +// secondNumbers.LastOrDefault(item => item > 3); + +// Console.Write(string.Format("{0}\t{1}\t{2}\t{3}", +// lastItemOfFirstList, +// lastItemIfFirstListBasedOnConditions, +// lastItemOfSecondList, +// lastItemOfSecondListBasedOnConditions +// )); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-58.cs b/9781430248606_sourcecode/Ch12/Listing 12-58.cs new file mode 100644 index 0000000..de24ce0 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-58.cs @@ -0,0 +1,20 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List +// { +// "One" +// }; +// var result = numbers.Single(); +// Console.WriteLine("{0}", result); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-60.cs b/9781430248606_sourcecode/Ch12/Listing 12-60.cs new file mode 100644 index 0000000..4288bb9 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-60.cs @@ -0,0 +1,20 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List +// { +// "One","Four" +// }; +// var result = numbers.Single(x => x.Length > 3); +// Console.WriteLine("{0}", result); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-61.cs b/9781430248606_sourcecode/Ch12/Listing 12-61.cs new file mode 100644 index 0000000..da55642 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-61.cs @@ -0,0 +1,29 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList listStringWithoutItem = new List(); +// IList listStringWithItem = new List() { "One" }; +// IList listInt = new List(); +// IList listChar = new List(); +// IList listLong = new List(); +// IList listDouble = new List(); + +// Console.WriteLine("string : {0}", +// listStringWithoutItem.SingleOrDefault()); +// Console.WriteLine("string : {0}", +// listStringWithItem.SingleOrDefault()); +// Console.WriteLine("int : {0}", listInt.SingleOrDefault()); +// Console.WriteLine("char : {0}", listChar.SingleOrDefault()); +// Console.WriteLine("long : {0}", listLong.SingleOrDefault()); +// Console.WriteLine("double : {0}", listDouble.SingleOrDefault()); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-63.cs b/9781430248606_sourcecode/Ch12/Listing 12-63.cs new file mode 100644 index 0000000..d8b1c7e --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-63.cs @@ -0,0 +1,21 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List() +// { +// "One","Two","Three" +// }; + +// var elementAt = numbers.ElementAt(1); + +// Console.WriteLine(elementAt); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-66.cs b/9781430248606_sourcecode/Ch12/Listing 12-66.cs new file mode 100644 index 0000000..c3f6990 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-66.cs @@ -0,0 +1,39 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Linq.Expressions; +//namespace Ch12 +//{ +// public struct MyStruct +// { +// public string Name { get; set; } +// } +// public class Person +// { +// public string PersonID { get; set; } +// public int PersonAge { get; set; } +// } +// class Program +// { +// static void Main(string[] args) +// { +// List series = new List { "One", "Two", "Three" }; +// List names = new List +// { +// new MyStruct{ Name="A"}, +// new MyStruct{ Name="B"}, +// }; +// List persons = new List +// { +// new Person { PersonID = "PA_01", PersonAge = 6 }, +// new Person { PersonID = "PB_01", PersonAge = 7 }, +// }; +// // outout will be null +// var item = series.ElementAtOrDefault(8); +// // Output contain an instnce of MyStruct in where Name will be null +// var name = names.ElementAtOrDefault(8); +// //Output will be null +// var person = persons.ElementAtOrDefault(8); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-67.cs b/9781430248606_sourcecode/Ch12/Listing 12-67.cs new file mode 100644 index 0000000..b108a82 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-67.cs @@ -0,0 +1,44 @@ +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { + +// IList persons = new List(); +// IList numbers = new List(); +// IList names = new List(); +// /* Output: A list with 1 item with the null value */ +// var defaultPersons = persons.DefaultIfEmpty(); +// /*Output: A list with 1 item with the 0 value */ +// var defaultNumbers = numbers.DefaultIfEmpty().ToList(); +// /* Output: A list with 1 item with the null value */ +// var defaultNames = names.DefaultIfEmpty(); +// } +// } + +// class Person +// { +// public string Name +// { +// get; +// set; +// } + +// public string Address +// { +// get; +// set; +// } + +// public int Age +// { +// get; +// set; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-69.cs b/9781430248606_sourcecode/Ch12/Listing 12-69.cs new file mode 100644 index 0000000..7ff5648 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-69.cs @@ -0,0 +1,15 @@ +//using System; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// var emptyList = Enumerable.Empty(); + +// Console.WriteLine(emptyList.Count()); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-7.cs b/9781430248606_sourcecode/Ch12/Listing 12-7.cs new file mode 100644 index 0000000..2e94fef --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-7.cs @@ -0,0 +1,21 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List() +// { +// "One","Two","Three", "Four","Five" +// }; + +// var result = numbers.SkipWhile(number => number.Length == 3); +// result.ToList().ForEach(number => Console.WriteLine(number)); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-72.cs b/9781430248606_sourcecode/Ch12/Listing 12-72.cs new file mode 100644 index 0000000..6a0fb75 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-72.cs @@ -0,0 +1,14 @@ +//using System; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Enumerable.Range(1, 10).ToList().ForEach(x => +// Console.Write("{0}\t", x)); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-75.cs b/9781430248606_sourcecode/Ch12/Listing 12-75.cs new file mode 100644 index 0000000..d51075e --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-75.cs @@ -0,0 +1,15 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Enumerable.Repeat(1, 5).ToList(). +// ForEach(x => Console.Write("{0}\t", x)); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-76.cs b/9781430248606_sourcecode/Ch12/Listing 12-76.cs new file mode 100644 index 0000000..02ade3c --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-76.cs @@ -0,0 +1,18 @@ +//using System; +//using System.Collections; +//using System.Linq; +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// ArrayList numbers = new ArrayList(); +// numbers.Add("One"); +// numbers.Add("Two"); +// numbers.Add("Three"); +// numbers.Cast().Select(number => number).ToList().ForEach( +// number => Console.Write("{0}\t", number)); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-77.cs b/9781430248606_sourcecode/Ch12/Listing 12-77.cs new file mode 100644 index 0000000..41bbbbf --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-77.cs @@ -0,0 +1,22 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList firstList = new List() +// { +// 1,2,3,4 +// }; + +// var result = firstList.ToArray(); +// result.ToList().ForEach(x => +// Console.Write(string.Format("{0}\t", x))); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-78.cs b/9781430248606_sourcecode/Ch12/Listing 12-78.cs new file mode 100644 index 0000000..9c9d063 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-78.cs @@ -0,0 +1,35 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List() +// { +// "One", +// "Two", +// 1, +// 2, +// "Three", +// new Person +// { +// Name="A Person" +// } +// }; + +// var filteredNumbers = numbers.OfType(); + +// filteredNumbers.ToList().ForEach(x => Console.Write("{0}\t", x)); +// Console.WriteLine(); +// } +// } + +// public class Person +// { +// public string Name { get; set; } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-79.cs b/9781430248606_sourcecode/Ch12/Listing 12-79.cs new file mode 100644 index 0000000..17b236f --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-79.cs @@ -0,0 +1,58 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList persons = new List() +// { +// new Person(){ Name="Person A", Address= "Address of A", +// Id= 111111}, +// new Person(){ Name="Person B", Address= "Address of B", +// Id= 111112}, +// new Person(){ Name="Person C", Address= "Address of C", +// Id= 111113}, +// new Person(){ Name="Person D", Address= "Address of D", +// Id= 111114}, +// }; + +// var result = persons.ToDictionary(person => person.Id); + +// foreach (KeyValuePair person in result) +// { +// Console.WriteLine("{0,-15} {1,-20}{2,-20}{3,-20}", +// person.Key, +// person.Value.Name, +// person.Value.Address, +// person.Value.Id); +// } +// } +// } + + +// public class Person +// { +// public string Name +// { +// get; +// set; +// } + +// public string Address +// { +// get; +// set; +// } + +// public double Id +// { +// get; +// set; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-82.cs b/9781430248606_sourcecode/Ch12/Listing 12-82.cs new file mode 100644 index 0000000..58be915 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-82.cs @@ -0,0 +1,23 @@ +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; +//using System; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList numbers = new List() +// { +// 1,2,3,4,5,6,7,8,9,10 +// }; + +// var result = numbers.Where(x => x > 3).ToList(); + +// result.ForEach(x => Console.Write("{0}\t", x)); +// Console.WriteLine(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-84.cs b/9781430248606_sourcecode/Ch12/Listing 12-84.cs new file mode 100644 index 0000000..ff0f0da --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-84.cs @@ -0,0 +1,51 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// List persons = CreatePersonList(); + +// var result = persons.ToLookup( +// (key) => key.Name, +// (groupItem) => groupItem.Address); + +// result.ToList().ForEach(item => +// { +// Console.Write("Key:{0,11}\nValue:\t{1,12}\n", +// item.Key, +// string.Join("\n\t", item.Select(groupItem => +// groupItem).ToArray())); +// }); +// } + +// private static List CreatePersonList() +// { +// return new List() +// { +// new Person{ Name="APerson", Address="APerson's Address"}, +// new Person{ Name="AAPerson", Address="AAPerson's Address"}, +// new Person{ Name="APerson", +// Address="APerson's Second Address"}, +// new Person{ Name="BPerson", Address="BPerson's Address"}, +// new Person{ Name="BBPerson", Address="BBPerson's Address"}, +// new Person{ Name="BPerson", +// Address="BPerson's Second Address"}, +// new Person{ Name="CPerson", Address="CPerson's Address"}, +// new Person{ Name="CCPerson", Address="CCPerson's Address"}, +// new Person{ Name="CPerson", +// Address="CPerson's Second Address"}, +// }; +// } +// } + +// public class Person +// { +// public string Name { get; set; } +// public string Address { get; set; } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-85.cs b/9781430248606_sourcecode/Ch12/Listing 12-85.cs new file mode 100644 index 0000000..9777571 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-85.cs @@ -0,0 +1,27 @@ +//using System; +//using System.Collections; +//using System.Collections.Generic; +//using System.Linq; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList firstList = new List() +// { +// 1,2,3,4 +// }; + +// IList secondList = new List() +// { +// "One","Two","Three","Four" +// }; + +// var result = firstList.Zip(secondList, (x, y) => x + ":\t" + y); + +// result.ToList().ForEach(x => Console.WriteLine(x)); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Listing 12-9.cs b/9781430248606_sourcecode/Ch12/Listing 12-9.cs new file mode 100644 index 0000000..ef1f469 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Listing 12-9.cs @@ -0,0 +1,23 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Text; + +//namespace Ch12 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// IList series = new List() +// { +// 1,2,3,4,5,6,7 +// }; + +// series.Take(4) +// .ToList() +// .ForEach(number => +// Console.Write(string.Format("{0}\t", number))); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch12/Program.cs b/9781430248606_sourcecode/Ch12/Program.cs new file mode 100644 index 0000000..6453256 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Program.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Ch12 +{ + class Program + { + static void Main(string[] args) + { + IList numbers = new List() + { + "One", "Two", "Three", "Four", "Five", "Six", "Seven" + }; + + var numbersLengthThree = + numbers.Where(x => x.Length == 3).Select(x => x).ToList(); + + numbersLengthThree.ForEach(x => Console.WriteLine(x)); + } + } +} diff --git a/9781430248606_sourcecode/Ch12/Properties/AssemblyInfo.cs b/9781430248606_sourcecode/Ch12/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..381030d --- /dev/null +++ b/9781430248606_sourcecode/Ch12/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ch12")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ch12")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3ae25c50-bae2-46f7-8d37-8aa4115bc4b8")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9781430248606_sourcecode/Ch12/app.config b/9781430248606_sourcecode/Ch12/app.config new file mode 100644 index 0000000..c5e1dae --- /dev/null +++ b/9781430248606_sourcecode/Ch12/app.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch12/bin/Debug/Ch12.vshost.exe b/9781430248606_sourcecode/Ch12/bin/Debug/Ch12.vshost.exe new file mode 100644 index 0000000..212bd7f Binary files /dev/null and b/9781430248606_sourcecode/Ch12/bin/Debug/Ch12.vshost.exe differ diff --git a/9781430248606_sourcecode/Ch12/bin/Debug/Ch12.vshost.exe.config b/9781430248606_sourcecode/Ch12/bin/Debug/Ch12.vshost.exe.config new file mode 100644 index 0000000..c5e1dae --- /dev/null +++ b/9781430248606_sourcecode/Ch12/bin/Debug/Ch12.vshost.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch12/bin/Debug/Ch12.vshost.exe.manifest b/9781430248606_sourcecode/Ch12/bin/Debug/Ch12.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/9781430248606_sourcecode/Ch12/bin/Debug/Ch12.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/9781430248606_sourcecode/Ch12/bin/Release/Ch12.exe b/9781430248606_sourcecode/Ch12/bin/Release/Ch12.exe new file mode 100644 index 0000000..83e236f Binary files /dev/null and b/9781430248606_sourcecode/Ch12/bin/Release/Ch12.exe differ diff --git a/9781430248606_sourcecode/Ch12/bin/Release/Ch12.exe.config b/9781430248606_sourcecode/Ch12/bin/Release/Ch12.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/bin/Release/Ch12.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch12/bin/Release/Ch12.pdb b/9781430248606_sourcecode/Ch12/bin/Release/Ch12.pdb new file mode 100644 index 0000000..f2553fc Binary files /dev/null and b/9781430248606_sourcecode/Ch12/bin/Release/Ch12.pdb differ diff --git a/9781430248606_sourcecode/Ch12/bin/Release/Ch12.vshost.exe b/9781430248606_sourcecode/Ch12/bin/Release/Ch12.vshost.exe new file mode 100644 index 0000000..bb84a51 Binary files /dev/null and b/9781430248606_sourcecode/Ch12/bin/Release/Ch12.vshost.exe differ diff --git a/9781430248606_sourcecode/Ch12/bin/Release/Ch12.vshost.exe.config b/9781430248606_sourcecode/Ch12/bin/Release/Ch12.vshost.exe.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/bin/Release/Ch12.vshost.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch12/bin/Release/Ch12.vshost.exe.manifest b/9781430248606_sourcecode/Ch12/bin/Release/Ch12.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/9781430248606_sourcecode/Ch12/bin/Release/Ch12.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/9781430248606_sourcecode/Ch12/obj/x86/Debug/Ch12.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch12/obj/x86/Debug/Ch12.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..a5937f1 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/obj/x86/Debug/Ch12.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch12\bin\Debug\Ch12.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch12\bin\Debug\Ch12.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch12\bin\Debug\Ch12.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch12\obj\x86\Debug\Ch12.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch12\obj\x86\Debug\Ch12.pdb diff --git a/9781430248606_sourcecode/Ch12/obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache b/9781430248606_sourcecode/Ch12/obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache new file mode 100644 index 0000000..bdb56e3 Binary files /dev/null and b/9781430248606_sourcecode/Ch12/obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/9781430248606_sourcecode/Ch12/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch12/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..ca3d0d8 Binary files /dev/null and b/9781430248606_sourcecode/Ch12/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch12/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/9781430248606_sourcecode/Ch12/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch12/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/9781430248606_sourcecode/Ch12/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch12/obj/x86/Release/Ch12.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch12/obj/x86/Release/Ch12.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..b30ca09 --- /dev/null +++ b/9781430248606_sourcecode/Ch12/obj/x86/Release/Ch12.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch12\bin\Release\Ch12.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch12\bin\Release\Ch12.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch12\bin\Release\Ch12.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch12\obj\x86\Release\ResolveAssemblyReference.cache +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch12\obj\x86\Release\Ch12.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch12\obj\x86\Release\Ch12.pdb diff --git a/9781430248606_sourcecode/Ch12/obj/x86/Release/Ch12.exe b/9781430248606_sourcecode/Ch12/obj/x86/Release/Ch12.exe new file mode 100644 index 0000000..83e236f Binary files /dev/null and b/9781430248606_sourcecode/Ch12/obj/x86/Release/Ch12.exe differ diff --git a/9781430248606_sourcecode/Ch12/obj/x86/Release/Ch12.pdb b/9781430248606_sourcecode/Ch12/obj/x86/Release/Ch12.pdb new file mode 100644 index 0000000..f2553fc Binary files /dev/null and b/9781430248606_sourcecode/Ch12/obj/x86/Release/Ch12.pdb differ diff --git a/9781430248606_sourcecode/Ch12/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch12/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..07b3c3f Binary files /dev/null and b/9781430248606_sourcecode/Ch12/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch13/Ch13.csproj b/9781430248606_sourcecode/Ch13/Ch13.csproj new file mode 100644 index 0000000..0378116 --- /dev/null +++ b/9781430248606_sourcecode/Ch13/Ch13.csproj @@ -0,0 +1,75 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {ACD755CA-C7A8-4059-9474-57AD95C0AA28} + Exe + Properties + Ch13 + Ch13 + v4.5 + + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch13/Ch13.csproj.user b/9781430248606_sourcecode/Ch13/Ch13.csproj.user new file mode 100644 index 0000000..55f44b9 --- /dev/null +++ b/9781430248606_sourcecode/Ch13/Ch13.csproj.user @@ -0,0 +1,6 @@ + + + + ShowAllFiles + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch13/Listing 13-1.cs b/9781430248606_sourcecode/Ch13/Listing 13-1.cs new file mode 100644 index 0000000..20d4424 --- /dev/null +++ b/9781430248606_sourcecode/Ch13/Listing 13-1.cs @@ -0,0 +1,22 @@ +//using System; + +//namespace Ch13 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// int a = 10, b = 5; +// Division div = new Division(); +// Console.WriteLine("{0}/{1}={2}", a, b, div.Divide(a, b)); +// } + +// public class Division +// { +// public int Divide(int a, int b) +// { +// return a / b; +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch13/Listing 13-10.cs b/9781430248606_sourcecode/Ch13/Listing 13-10.cs new file mode 100644 index 0000000..8bd72af --- /dev/null +++ b/9781430248606_sourcecode/Ch13/Listing 13-10.cs @@ -0,0 +1,32 @@ +//using System; + +//namespace Ch13 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// try +// { +// ExampleOfRethrow(); +// } +// catch (Exception exception) +// { +// Console.WriteLine(exception.StackTrace); +// } +// } + +// static void ExampleOfRethrow() +// { +// try +// { +// int a = 10, b = 0; +// var result = a / b; +// } +// catch +// { +// throw; +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch13/Listing 13-12.cs b/9781430248606_sourcecode/Ch13/Listing 13-12.cs new file mode 100644 index 0000000..e551138 --- /dev/null +++ b/9781430248606_sourcecode/Ch13/Listing 13-12.cs @@ -0,0 +1,26 @@ +//using System; + +//namespace Ch13 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// try +// { ExampleOfRethrow(); } + +// catch (Exception exception) +// { Console.WriteLine(exception.StackTrace); } +// } + +// static void ExampleOfRethrow() +// { +// try +// { +// int a = 10, b = 0; +// var result = a / b; +// } +// catch (Exception ex) { throw; } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch13/Listing 13-14.cs b/9781430248606_sourcecode/Ch13/Listing 13-14.cs new file mode 100644 index 0000000..3293366 --- /dev/null +++ b/9781430248606_sourcecode/Ch13/Listing 13-14.cs @@ -0,0 +1,29 @@ +//using System; + +//namespace Ch13 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// try +// { ExampleOfRethrow(); } + +// catch (Exception exception) +// { Console.WriteLine(exception.StackTrace); } +// } + +// static void ExampleOfRethrow() +// { +// try +// { +// int a = 10, b = 0; +// var result = a / b; +// } +// catch (Exception ex) +// { +// throw ex; +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch13/Listing 13-16.cs b/9781430248606_sourcecode/Ch13/Listing 13-16.cs new file mode 100644 index 0000000..2a59050 --- /dev/null +++ b/9781430248606_sourcecode/Ch13/Listing 13-16.cs @@ -0,0 +1,61 @@ +//using System; + +//namespace Ch13 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// try +// { +// Year year = new Year(); +// year.GetMonth(22); +// } +// catch (Exception exception) +// { +// Console.WriteLine("{0}", exception.StackTrace); +// } +// } +// } + +// public class Year +// { +// public string GetMonth(int position) +// { +// try +// { +// MonthNameFinder monthFinder = new MonthNameFinder(); +// return monthFinder.Find(position); +// } +// catch (Exception exception) +// { +// throw; +// } +// } +// } + +// public class MonthNameFinder +// { +// private string[] months = +// { +// "January", "February", +// "March", "April", +// "May", "June", +// "July", "August", +// "September", "October", +// "November", "December" +// }; + +// public string Find(int whichMonth) +// { +// try +// { +// return months[whichMonth]; +// } +// catch (Exception exception) +// { +// throw; +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch13/Listing 13-18.cs b/9781430248606_sourcecode/Ch13/Listing 13-18.cs new file mode 100644 index 0000000..22f765e --- /dev/null +++ b/9781430248606_sourcecode/Ch13/Listing 13-18.cs @@ -0,0 +1,46 @@ +//using System; + +//namespace Ch13 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Division div = new Division(); +// div.Divide(100, 0); +// Console.ReadLine(); +// } + +// public class Division +// { +// public int Divide(int a, int b) +// { +// try +// { +// return a / b; +// } + +// catch (IndexOutOfRangeException indexOutOfRangeException) +// { +// Console.WriteLine("IndexOutOfRangeException"); +// } +// catch (ArgumentException argumentException) +// { +// Console.WriteLine("ArgumentException"); +// } +// catch (DivideByZeroException divideByZeroException) +// { +// Console.WriteLine("{0}\n{1}", +// "DivideByZeroException", +// "This handler block will execute."); +// } +// catch (Exception exception) +// { +// Console.WriteLine("{0}", +// "It will execute when there is no best matched found."); +// } +// return -1; +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch13/Listing 13-19.cs b/9781430248606_sourcecode/Ch13/Listing 13-19.cs new file mode 100644 index 0000000..e8cfbff --- /dev/null +++ b/9781430248606_sourcecode/Ch13/Listing 13-19.cs @@ -0,0 +1,21 @@ +//using System; +//using System.Text; +//using System.IO; + +//namespace Ch13 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// StringBuilder sb = new StringBuilder(); +// sb.Append("StringBuilder\n"); + +// using (StringWriter sw = new StringWriter(sb)) +// { +// sw.WriteLine("StringWriter"); +// } +// Console.WriteLine("{0}", sb.ToString()); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch13/Listing 13-3.cs b/9781430248606_sourcecode/Ch13/Listing 13-3.cs new file mode 100644 index 0000000..08547be --- /dev/null +++ b/9781430248606_sourcecode/Ch13/Listing 13-3.cs @@ -0,0 +1,35 @@ +//using System; + +//namespace Ch13 +//{ +// class MainClass +// { +// static void Main(string[] args) +// { +// ExceptionInMethodStateDescription exInMSD = +// new ExceptionInMethodStateDescription(); +// exInMSD.MethodOne(); +// exInMSD.MethodTwo(); +// exInMSD.MethodThree(); +// } +// } + +// public class ExceptionInMethodStateDescription +// { +// public void MethodOne() +// { +// try { } +// catch (IndexOutOfRangeException indexOutOfRangeException) { } +// } +// public void MethodTwo() +// { +// try { } +// catch (ArgumentException argumentException) { } +// } +// public void MethodThree() +// { +// try { } +// catch (Exception exception) { } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch13/Listing 13-4.cs b/9781430248606_sourcecode/Ch13/Listing 13-4.cs new file mode 100644 index 0000000..392f555 --- /dev/null +++ b/9781430248606_sourcecode/Ch13/Listing 13-4.cs @@ -0,0 +1,33 @@ +///* First version of the Exception handling */ + +//using System; + +//namespace Ch13 +//{ +// class MainClass +// { +// static void Main(string[] args) +// { +// Division div = new Division(); +// div.Divide(100, 0); +// } +// } +// public class Division +// { +// public int Divide(int a, +// int b) +// { +// try +// { +// return a / b; +// } +// /* Exception is handled in here by catching all the exception. */ +// catch (Exception exception) +// { +// Console.WriteLine( +// exception.StackTrace); +// return -1; +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch13/Listing 13-5.cs b/9781430248606_sourcecode/Ch13/Listing 13-5.cs new file mode 100644 index 0000000..a5d1a43 --- /dev/null +++ b/9781430248606_sourcecode/Ch13/Listing 13-5.cs @@ -0,0 +1,51 @@ +//using System; + +//namespace Ch13 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// try +// { +// Salary salary = new Salary(); +// salary.CalculateSalary(10, 0); +// } +// catch (Exception exception) +// { +// Console.WriteLine("An error occured."); +// } +// } +// } + +// public class Salary +// { +// public int CalculateSalary(int week, int rate) +// { +// try +// { +// Calculator calculator = new Calculator(); +// return week * calculator.Divide(week, rate); +// } +// catch (DivideByZeroException divideByZeroException) +// { +// throw; +// } +// } +// } + +// public class Calculator +// { +// public int Divide(int a, int b) +// { +// try +// { +// return a / b; +// } +// catch +// { +// throw; +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch13/Listing 13-6.cs b/9781430248606_sourcecode/Ch13/Listing 13-6.cs new file mode 100644 index 0000000..9e9a70a --- /dev/null +++ b/9781430248606_sourcecode/Ch13/Listing 13-6.cs @@ -0,0 +1,44 @@ +//using System; + +//namespace Ch13 +//{ +// class MainClass +// { +// static void Main(string[] args) +// { +// ExampleOfExceptionUsage eeu = new ExampleOfExceptionUsage(); +// } +// } + +// public class ExampleOfExceptionUsage +// { +// public void DoSomething() +// { +// try +// { +// /* Do some operation */ +// } + +// catch (ArgumentException argumentException) +// { +// /* handle ArgumentException exception */ +// } + +// catch (IndexOutOfRangeException indexOutOfRangeException) +// { +// /*handle IndexOutOfRangeException */ +// } + +// catch (Exception exception) +// { +// /* handle exception in general in here if ArgumentException +// * and IndexOutOfRangeException did not occurred. */ +// } + +// finally +// { +// Console.WriteLine("It will execute all the time"); +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch13/Listing 13-8.cs b/9781430248606_sourcecode/Ch13/Listing 13-8.cs new file mode 100644 index 0000000..b1b9f88 --- /dev/null +++ b/9781430248606_sourcecode/Ch13/Listing 13-8.cs @@ -0,0 +1,13 @@ +//using System; + +//namespace Ch13 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// throw new Exception("An exception object"); +// Console.WriteLine("This will never execute."); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch13/Program.cs b/9781430248606_sourcecode/Ch13/Program.cs new file mode 100644 index 0000000..c3de65b --- /dev/null +++ b/9781430248606_sourcecode/Ch13/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace Ch13 +{ + class MainClass + { + static void Main(string[] args) + { + /// ExampleOfExceptionUsage eeu = new ExampleOfExceptionUsage(); + } + } +} \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch13/Properties/AssemblyInfo.cs b/9781430248606_sourcecode/Ch13/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..03bd1a6 --- /dev/null +++ b/9781430248606_sourcecode/Ch13/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ch13")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ch13")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("338dd4f0-fdba-4ea6-88e4-3072d7e89748")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9781430248606_sourcecode/Ch13/app.config b/9781430248606_sourcecode/Ch13/app.config new file mode 100644 index 0000000..c5e1dae --- /dev/null +++ b/9781430248606_sourcecode/Ch13/app.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch13/bin/Debug/Ch13.vshost.exe b/9781430248606_sourcecode/Ch13/bin/Debug/Ch13.vshost.exe new file mode 100644 index 0000000..718c978 Binary files /dev/null and b/9781430248606_sourcecode/Ch13/bin/Debug/Ch13.vshost.exe differ diff --git a/9781430248606_sourcecode/Ch13/bin/Debug/Ch13.vshost.exe.config b/9781430248606_sourcecode/Ch13/bin/Debug/Ch13.vshost.exe.config new file mode 100644 index 0000000..e59af44 --- /dev/null +++ b/9781430248606_sourcecode/Ch13/bin/Debug/Ch13.vshost.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch13/bin/Debug/Ch13.vshost.exe.manifest b/9781430248606_sourcecode/Ch13/bin/Debug/Ch13.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/9781430248606_sourcecode/Ch13/bin/Debug/Ch13.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/9781430248606_sourcecode/Ch13/bin/Release/Ch13.exe b/9781430248606_sourcecode/Ch13/bin/Release/Ch13.exe new file mode 100644 index 0000000..241d960 Binary files /dev/null and b/9781430248606_sourcecode/Ch13/bin/Release/Ch13.exe differ diff --git a/9781430248606_sourcecode/Ch13/bin/Release/Ch13.exe.config b/9781430248606_sourcecode/Ch13/bin/Release/Ch13.exe.config new file mode 100644 index 0000000..e59af44 --- /dev/null +++ b/9781430248606_sourcecode/Ch13/bin/Release/Ch13.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch13/bin/Release/Ch13.pdb b/9781430248606_sourcecode/Ch13/bin/Release/Ch13.pdb new file mode 100644 index 0000000..fc8cee2 Binary files /dev/null and b/9781430248606_sourcecode/Ch13/bin/Release/Ch13.pdb differ diff --git a/9781430248606_sourcecode/Ch13/bin/Release/Ch13.vshost.exe b/9781430248606_sourcecode/Ch13/bin/Release/Ch13.vshost.exe new file mode 100644 index 0000000..58da521 Binary files /dev/null and b/9781430248606_sourcecode/Ch13/bin/Release/Ch13.vshost.exe differ diff --git a/9781430248606_sourcecode/Ch13/bin/Release/Ch13.vshost.exe.config b/9781430248606_sourcecode/Ch13/bin/Release/Ch13.vshost.exe.config new file mode 100644 index 0000000..e59af44 --- /dev/null +++ b/9781430248606_sourcecode/Ch13/bin/Release/Ch13.vshost.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch13/bin/Release/Ch13.vshost.exe.manifest b/9781430248606_sourcecode/Ch13/bin/Release/Ch13.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/9781430248606_sourcecode/Ch13/bin/Release/Ch13.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/9781430248606_sourcecode/Ch13/obj/x86/Debug/Ch13.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch13/obj/x86/Debug/Ch13.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..5b0b969 --- /dev/null +++ b/9781430248606_sourcecode/Ch13/obj/x86/Debug/Ch13.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch13\bin\Debug\Ch13.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch13\bin\Debug\Ch13.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch13\bin\Debug\Ch13.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch13\obj\x86\Debug\Ch13.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch13\obj\x86\Debug\Ch13.pdb diff --git a/9781430248606_sourcecode/Ch13/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch13/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..717e6e9 Binary files /dev/null and b/9781430248606_sourcecode/Ch13/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch13/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/9781430248606_sourcecode/Ch13/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch13/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/9781430248606_sourcecode/Ch13/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch13/obj/x86/Release/Ch13.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch13/obj/x86/Release/Ch13.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..923611c --- /dev/null +++ b/9781430248606_sourcecode/Ch13/obj/x86/Release/Ch13.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch13\bin\Release\Ch13.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch13\bin\Release\Ch13.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch13\bin\Release\Ch13.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch13\obj\x86\Release\ResolveAssemblyReference.cache +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch13\obj\x86\Release\Ch13.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch13\obj\x86\Release\Ch13.pdb diff --git a/9781430248606_sourcecode/Ch13/obj/x86/Release/Ch13.exe b/9781430248606_sourcecode/Ch13/obj/x86/Release/Ch13.exe new file mode 100644 index 0000000..241d960 Binary files /dev/null and b/9781430248606_sourcecode/Ch13/obj/x86/Release/Ch13.exe differ diff --git a/9781430248606_sourcecode/Ch13/obj/x86/Release/Ch13.pdb b/9781430248606_sourcecode/Ch13/obj/x86/Release/Ch13.pdb new file mode 100644 index 0000000..fc8cee2 Binary files /dev/null and b/9781430248606_sourcecode/Ch13/obj/x86/Release/Ch13.pdb differ diff --git a/9781430248606_sourcecode/Ch13/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch13/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..b5934e9 Binary files /dev/null and b/9781430248606_sourcecode/Ch13/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch14/Ch14.csproj b/9781430248606_sourcecode/Ch14/Ch14.csproj new file mode 100644 index 0000000..f717342 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Ch14.csproj @@ -0,0 +1,87 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {C31EF547-CA0A-477F-9A40-0D0347906E6B} + Exe + Properties + Ch14 + Ch14 + v4.5 + + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch14/Listing 14-1.cs b/9781430248606_sourcecode/Ch14/Listing 14-1.cs new file mode 100644 index 0000000..5f69a88 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-1.cs @@ -0,0 +1,29 @@ +//using System; +//using System.Diagnostics; +//using System.Threading; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// Stopwatch stopwatch = new Stopwatch(); +// stopwatch.Start(); +// Method1(); +// Method2(); +// Method3(); +// Method4(); +// Method5(); +// stopwatch.Stop(); +// Console.WriteLine("Elapsed time: {0}ms", +// stopwatch.ElapsedMilliseconds); +// Console.ReadKey(); +// } +// static void Method1() { Thread.Sleep(10); } +// static void Method2() { Thread.Sleep(10); } +// static void Method3() { Thread.Sleep(10); } +// static void Method4() { Thread.Sleep(10); } +// static void Method5() { Thread.Sleep(10); } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-10.cs b/9781430248606_sourcecode/Ch14/Listing 14-10.cs new file mode 100644 index 0000000..f47aed9 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-10.cs @@ -0,0 +1,20 @@ +//using System; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// Task displayTask = Task.Run( +// () => Console.WriteLine("async in C# 5.0")); + +// Console.WriteLine( +// "Task completion status : {0}, waiting to finish....", +// displayTask.IsCompleted); +// displayTask.Wait(); +// Console.ReadLine(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-11.cs b/9781430248606_sourcecode/Ch14/Listing 14-11.cs new file mode 100644 index 0000000..1e377d8 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-11.cs @@ -0,0 +1,43 @@ +//using System; +//using System.Linq; +//using System.Runtime.CompilerServices; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// ShowEvenNumbers(); +// Console.WriteLine("Waiting....."); +// for (int i = 0; i <= Int16.MaxValue * 100; ++i) ; +// Console.ReadLine(); +// } + +// static void ShowEvenNumbers() +// { +// /* A Task is instantiated*/ +// Task evenNumbersTask = Task.Run( +// () => Enumerable.Range(1, +// new Random().Next(Int16.MaxValue)).Count( +// item => item % 2 == 0)); + +// /* Retrieved the awaiter from the Task instantiated earlier */ +// TaskAwaiter awaiter = evenNumbersTask.GetAwaiter(); + +// /* Setup the continuation block in the awaiter of the Task +// * evenNumbersTask */ +// awaiter.OnCompleted(() => +// { +// /* Continuation code block */ +// Console.WriteLine("Complete, Total no of even : {0}", +// awaiter.GetResult()); +// }); + +// /* Following line or lines is not part of the continuation +// * code block in relation to the Task evenNumbersTask */ +// Console.WriteLine("Schedule to complete..."); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-14.cs b/9781430248606_sourcecode/Ch14/Listing 14-14.cs new file mode 100644 index 0000000..f7740b5 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-14.cs @@ -0,0 +1,33 @@ +//using System; +//using System.Linq; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// ShowEvenNumbers(); +// Console.WriteLine("Waiting....."); +// for (int i = 0; i <= Int16.MaxValue * 100; ++i) ; +// Console.ReadLine(); +// } + +// static void ShowEvenNumbers() +// { +// Task evenNumbersTask = Task.Run( +// () => Enumerable.Range(1, +// new Random().Next(Int16.MaxValue)). +// Count(item => item % 2 == 0)); + +// evenNumbersTask.ContinueWith(task => +// { +// Console.WriteLine("Complete, Total no of even : {0}", +// task.Result); +// }); + +// Console.WriteLine("Schedule to complete..."); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-18.cs b/9781430248606_sourcecode/Ch14/Listing 14-18.cs new file mode 100644 index 0000000..0587cb2 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-18.cs @@ -0,0 +1,84 @@ +//using System; +//using System.Threading; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// /*Instantiates an instance of the State machine */ +// StateMachine sm = new StateMachine(); + +// /*Initialize the State machine with it's default value*/ +// sm.State = 1; + +// /* Start the State machine */ +// sm.MoveNext(); + +// /* Queue the captured execution context with the workitem in the +// * ThreadPool to process later. */ +// ThreadPool.QueueUserWorkItem(state => +// RunLaterOn( +// /* Get the current execution context */ +// CaptureExecutionContext(), +// /* pass the callback code block */ +// new Action(Callback), +// /* The State machine which maintains the state */ +// sm)); + +// /* Do something else. */ +// for (int i = 0; i <= Int16.MaxValue; ++i) +// if (i % byte.MaxValue == 0) +// Console.Write("."); +// Console.ReadLine(); +// } + +// /* This code block capture the current execution context */ +// static ExecutionContext CaptureExecutionContext() +// { +// return ExecutionContext.Capture(); +// } + +// /* This code block will run the callback code block on the +// * captured execution context*/ +// static void RunLaterOn( +// ExecutionContext context, Action callback, object state) +// { +// ExecutionContext.Run(context, +// new ContextCallback(Callback), state); +// } + +// /* This code block used as the callback */ +// static void Callback(object state) +// { +// ((StateMachine)state).MoveNext(); +// } +// } + +// /* The State machine used to maintain the state of the operation */ +// public class StateMachine +// { +// public int State { get; set; } + +// public void MoveNext() +// { +// switch (State) +// { +// case 0: +// Console.Write("State 0"); +// State = 1; +// break; +// case 1: +// Console.Write("State 1"); +// for (int i = 0; i <= byte.MaxValue; ++i) ; +// State = 0; +// break; +// default: +// Console.Write("State -1"); +// State = 10; +// break; +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-20.cs b/9781430248606_sourcecode/Ch14/Listing 14-20.cs new file mode 100644 index 0000000..cdde08e --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-20.cs @@ -0,0 +1,37 @@ +//using System; +//using System.Linq; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// int limit = new Random().Next(Int32.MaxValue); + +// Task evenNumbersTask = Task.Run( +// () => Enumerable.Range(1, limit).Count(item => +// { +// if (item == Int16.MaxValue) +// /* Out of Range will be concat with the original +// * Framework given exception message */ +// throw new ArgumentOutOfRangeException( +// "Out of Range...."); +// return item % 2 == 0; +// })); +// try +// { +// evenNumbersTask.Wait(); /* Wait for the Exception to occur. */ +// } +// catch (AggregateException aggregateException) +// { +// aggregateException +// .InnerExceptions +// .Where(item => item is ArgumentOutOfRangeException) +// .ToList() /* Contains ArgumentOutOfRangeException */ +// .ForEach(age => Console.WriteLine(age.Message)); +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-21.cs b/9781430248606_sourcecode/Ch14/Listing 14-21.cs new file mode 100644 index 0000000..a51f1f8 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-21.cs @@ -0,0 +1,44 @@ +//using System; +//using System.Linq; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// int limit = new Random().Next(Int32.MaxValue); + +// var evenNumbersTask = Task.Factory.StartNew(() => +// { +// var r = Task.Factory.StartNew(() => +// { +// Enumerable.Range(1, limit).Count(item => +// { +// if (item == Int16.MaxValue) +// /* Out of Range will be concat with the original +// * Framework given exception message */ +// throw new ArgumentOutOfRangeException( +// "Out of Range...."); +// return item % 2 == 0; +// }); +// }, TaskCreationOptions.AttachedToParent); +// }, TaskCreationOptions.AttachedToParent); + +// try +// { +// evenNumbersTask.Wait(); /* Wait for the Exception to occur. */ +// } +// catch (AggregateException aggregateException) +// { +// aggregateException +// .Flatten() +// .InnerExceptions +// .Where(item => item is ArgumentOutOfRangeException) +// .ToList() /* Contains ArgumentOutOfRangeException */ +// .ForEach(age => Console.WriteLine(age.Message)); +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-22.cs b/9781430248606_sourcecode/Ch14/Listing 14-22.cs new file mode 100644 index 0000000..4aaec53 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-22.cs @@ -0,0 +1,45 @@ +//using System; +//using System.Linq; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// int limit = new Random().Next(Int32.MaxValue); + +// var evenNumbersTask = Task.Factory.StartNew(() => +// { +// var r = Task.Factory.StartNew(() => +// { +// Enumerable.Range(1, limit).Count(item => +// { +// if (item == Int16.MaxValue) +// /* Out of Range will be concat with the original +// * Framework given exception message */ +// throw new ArgumentOutOfRangeException( +// "Out of Range...."); +// return item % 2 == 0; +// }); +// }); +// r.Wait(); +// }); + +// try +// { +// evenNumbersTask.Wait(); /* Wait for the Exception to occur. */ +// } +// catch (AggregateException aggregateException) +// { +// aggregateException +// .Flatten() +// .InnerExceptions +// .Where(item => item is ArgumentOutOfRangeException) +// .ToList() /* Contains ArgumentOutOfRangeException */ +// .ForEach(age => Console.WriteLine(age.Message)); +// } +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-23.cs b/9781430248606_sourcecode/Ch14/Listing 14-23.cs new file mode 100644 index 0000000..7ac94a8 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-23.cs @@ -0,0 +1,20 @@ +//using System; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// Task showNumber = ShowEvenNumbers(); +// Console.ReadLine(); +// } + +// /* The async modifier used to define the asynchronous method */ +// public static async Task ShowEvenNumbers() +// { +// await Task.Run(() => Console.WriteLine("Async Function")); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-24.cs b/9781430248606_sourcecode/Ch14/Listing 14-24.cs new file mode 100644 index 0000000..0b0e5b0 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-24.cs @@ -0,0 +1,23 @@ +//using System; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// Task showNumber = ShowEvenNumbers(); +// Console.ReadLine(); +// } + +// /* The async modifier used to define the asynchronous method */ +// public static async Task ShowEvenNumbers() +// { +// return await Task.Run(() => +// { +// Console.WriteLine("Async Function"); +// }); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-26.cs b/9781430248606_sourcecode/Ch14/Listing 14-26.cs new file mode 100644 index 0000000..97221b7 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-26.cs @@ -0,0 +1,66 @@ +//using System; +//using System.Linq; +//using System.Threading; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// Console.WriteLine("{0,15}{1,46}{2,15}", +// "Method", "Description", "Thread Id"); +// Console.WriteLine("{0,15}{1,46}{2,15}", +// "Main", "Start Processing.....", +// Thread.CurrentThread.ManagedThreadId); + +// /* Call an async method */ +// Task showNumber = ShowEvenNumbers(); + +// /* The for loop used to simulate as something else is executing +// * while the asynchronous operation is executing it's task.*/ +// for (int i = 0; i < Int64.MaxValue; ++i) +// if (i % Int32.MaxValue == 0) +// Console.WriteLine("{0,15}{1,46}{2,15}", +// "Main", "something else is doing......", +// Thread.CurrentThread.ManagedThreadId); +// /* Checking the Task whether it's completed or not */ +// else if (showNumber.IsCompleted) +// break; + +// Console.WriteLine("{0,15}{1,46}{2,15}", +// "Main", "Finished execution", +// Thread.CurrentThread.ManagedThreadId); +// Console.ReadLine(); +// } + +// public static async Task ShowEvenNumbers() +// { +// Console.WriteLine("{0,15}{1,46}{2,15}", "ShowEvenNumbers", +// "Processing is continuing.....", +// Thread.CurrentThread.ManagedThreadId); +// int limit = new Random().Next(Int32.MaxValue); +// string range = string.Format("({0},{1})", 1, limit); + +// /* Initialize and schedule a Task to run sometime later on.*/ +// Task evenNumbersTask = Task.Run( +// () => Enumerable.Range(1, limit).Count(item => item % 2 == 0)); + +// /* The await statement await the Task to complete later by +// * set up the continuation code block to execute after the +// * Task finishes it's job.*/ +// int count = await evenNumbersTask; + +// /* Following code block will be used as the continuation code +// * block for the evenNumbersTask and it will be setup by +// * the C# compiler. */ +// Console.WriteLine("{0,15}{1,46}{2,15}", "ShowEvenNumbers", +// string.Format("In {0} Total: {1} On Thread", range, count), +// Thread.CurrentThread.ManagedThreadId); +// Console.WriteLine("{0,15}{1,46}{2,15}", "ShowEvenNumbers", +// "Processing is finished.....", +// Thread.CurrentThread.ManagedThreadId); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-3.cs b/9781430248606_sourcecode/Ch14/Listing 14-3.cs new file mode 100644 index 0000000..c8ac53a --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-3.cs @@ -0,0 +1,29 @@ +//using System; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// /* A task will be instantiated and scheduled to run sometime +// * later on and +// * return the instance of the Task to displayTask variable. */ +// Task displayTask = Task.Run(() => +// Console.WriteLine("async in C# 5.0")); + +// /* Continue until the task completes */ +// while (true) +// { +// /* To check whether the task has completed or not */ +// if (displayTask.IsCompleted) +// { +// Console.WriteLine("Task completed!"); +// break; +// } +// } +// Console.ReadLine(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-32.cs b/9781430248606_sourcecode/Ch14/Listing 14-32.cs new file mode 100644 index 0000000..ed372a6 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-32.cs @@ -0,0 +1,41 @@ +//using System; +//using System.Linq; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// FireAndForget(); + +// for (int i = 0; i < Int32.MaxValue; ++i) +// { +// if (i % (Int16.MaxValue * 999) == 0) +// Console.Write("."); +// } +// Console.ReadLine(); +// } + +// public static async void FireAndForget() +// { +// var evenNumbersTask = Task.Run( +// () => +// { +// Enumerable.Range(1, 5).ToList().ForEach(itemOuter => +// { +// int limit = new Random().Next(Int16.MaxValue * 999); +// var result = Enumerable.Range( +// itemOuter, limit).Count(item => +// { +// return item % 2 == 0; +// }); +// Console.WriteLine( +// "\nProcessing and processed result {0}.", result); +// }); +// }); +// await evenNumbersTask; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-34.cs b/9781430248606_sourcecode/Ch14/Listing 14-34.cs new file mode 100644 index 0000000..e5f1f40 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-34.cs @@ -0,0 +1,37 @@ +//using System; +//using System.Linq; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// MultipleAwait(); + +// for (int i = 0; i < Int16.MaxValue * 8; ++i) +// { +// if (i / byte.MaxValue == 0) +// Console.Write(">"); +// } +// Console.WriteLine("Operation is completed."); +// Console.ReadLine(); +// } +// public static async void MultipleAwait() +// { +// await EvenNumbers(); +// await EvenNumbers(); +// } + +// public static async Task EvenNumbers() +// { +// int limit = new Random().Next(Int16.MaxValue); +// Task evenNumbersTask = Task.Run( +// () => Enumerable.Range(1, limit).Count( +// item => item % 2 == 0)); +// await evenNumbersTask; +// Console.WriteLine("\n" + evenNumbersTask.Result); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-38.cs b/9781430248606_sourcecode/Ch14/Listing 14-38.cs new file mode 100644 index 0000000..e4ac864 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-38.cs @@ -0,0 +1,43 @@ +//using System; +//using System.Linq; +//using System.Threading; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// CancellationTokenSource cancelSource = new CancellationTokenSource(); + +// /* Initialize the Task with the cancel Token from +// * the CancellationTokenSource */ +// Task showNumber = ShowEvenNumbers(cancelSource.Token); + +// /* Following for-loop simulates as something else is going on */ +// for (int i = 0; i < Int64.MaxValue; ++i) +// if (i == byte.MaxValue) +// { +// /* Call the Cancel method to cancel the task in sometime +// * when the Task was executing it's Task*/ +// cancelSource.Cancel(); +// break; +// } +// Console.WriteLine("Cancel"); +// Console.ReadLine(); +// } + +// public static async Task ShowEvenNumbers(CancellationToken cancelToken) +// { +// int limit = new Random().Next(Int32.MaxValue); +// string range = string.Format("({0},{1})", 1, limit); + +// /* Pass the cancel token to the Task */ +// Task evenNumbersTask = Task.Run( +// () => Enumerable.Range(1, limit).Count( +// item => item % 2 == 0), cancelToken); +// int count = await evenNumbersTask; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-4.cs b/9781430248606_sourcecode/Ch14/Listing 14-4.cs new file mode 100644 index 0000000..08c36e6 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-4.cs @@ -0,0 +1,25 @@ +//using System; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// /* An instance of the Task will be instantiated. */ +// Task displayTask = new Task( +// /* The Task will execute the Action block */ +// () => Console.WriteLine("async in C# 5.0"), +// /* Task creation options */ +// TaskCreationOptions.None +// ); + +// displayTask.Start(); +// /* The Task will execute sometimes later */ +// displayTask.Wait(); +// /* Explicitly wait for the task to finish */ +// Console.ReadLine(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-40.cs b/9781430248606_sourcecode/Ch14/Listing 14-40.cs new file mode 100644 index 0000000..759efeb --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-40.cs @@ -0,0 +1,48 @@ +//using System; +//using System.Linq; +//using System.Threading; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// CancellationTokenSource cancelSource = new +// CancellationTokenSource(); +// Progress progressReport = new Progress((status) => +// { +// Console.Clear(); +// Console.WriteLine(status + " %"); +// }); +// Task showNumber = ShowEvenNumbers(cancelSource.Token, +// progressReport); + +// for (int i = 0; i < Int64.MaxValue; ++i) +// if (i == Int32.MaxValue) +// { +// cancelSource.Cancel(); +// break; +// } +// Console.WriteLine("Cancel"); +// Console.ReadLine(); +// } + +// public static async Task ShowEvenNumbers( +// CancellationToken cancelToken, +// IProgress onProgressChanged) +// { +// int limit = new Random().Next(Int32.MaxValue); +// string range = string.Format("({0},{1})", 1, limit); + +// Task evenNumbersTask = Task.Run( +// () => Enumerable.Range(1, limit).Count(item => +// { +// onProgressChanged.Report((item * 100) / limit); +// return item % 2 == 0; +// }), cancelToken); +// int count = await evenNumbersTask; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-41.cs b/9781430248606_sourcecode/Ch14/Listing 14-41.cs new file mode 100644 index 0000000..2c136d8 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-41.cs @@ -0,0 +1,38 @@ +//using System; +//using System.Linq; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// Task combinedResult = TestWhenAll(); +// while (true) +// { +// if (combinedResult.IsCompleted) +// { +// Console.WriteLine("Finished : {0}", combinedResult.Result); +// break; +// } +// Console.Write("."); +// } +// Console.ReadLine(); +// } + +// public static async Task TestWhenAll() +// { +// int[] combinedResult = +// await Task.WhenAll(CountEvenNumbers(), +// CountEvenNumbers(), CountEvenNumbers()); +// return combinedResult.Sum(); +// } + +// public static async Task CountEvenNumbers() +// { +// return await Task.Run( +// () => Enumerable.Range(1, Int16.MaxValue).Count(x => x % 2 == 0)); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-42.cs b/9781430248606_sourcecode/Ch14/Listing 14-42.cs new file mode 100644 index 0000000..15ef608 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-42.cs @@ -0,0 +1,53 @@ +//using System; +//using System.Linq; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// Task combinedResult = TestWhenAll(); +// while (true) +// { +// if (combinedResult.IsCompleted) +// { +// Console.WriteLine("Finished : {0}", combinedResult.Result); +// break; +// } +// Console.Write("."); +// } +// Console.ReadLine(); +// } + +// public static async Task TestWhenAll() +// { +// int[] combinedResult = +// await Task.WhenAll(CountEvenNumbers(), +// ThrowAnException(), CountEvenNumbers()); +// return combinedResult.Sum(); +// } + +// public static async Task ThrowAnException() +// { +// return await Task.Run(() => +// { +// throw new Exception( +// "There is something wrong in the processing...."); +// return Enumerable.Range(1, Int16.MaxValue).Count( +// x => x % 2 == 0); +// }); +// } +// public static async Task CountEvenNumbers() +// { +// return await Task.Run(() => +// { +// int result = Enumerable.Range(1, Int16.MaxValue).Count( +// x => x % 2 == 0); +// Console.WriteLine(result); +// return result; +// }); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-43.cs b/9781430248606_sourcecode/Ch14/Listing 14-43.cs new file mode 100644 index 0000000..2ab0821 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-43.cs @@ -0,0 +1,38 @@ +//using System; +//using System.Linq; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// Task result = TestWhenAny(); +// while (true) +// { +// if (result.IsCompleted) +// { +// Console.WriteLine("Finished : {0}", result.Result); +// break; +// } +// Console.Write("."); +// } +// Console.ReadLine(); +// } + +// public static async Task TestWhenAny() +// { +// Task firstCompleted = +// await Task.WhenAny(CountEvenNumbers(), +// CountEvenNumbers(), CountEvenNumbers()); +// return firstCompleted.Result; +// } + +// public static async Task CountEvenNumbers() +// { +// return await Task.Run(() => Enumerable.Range(1, +// Int16.MaxValue).Count(x => x % 2 == 0)); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-44.cs b/9781430248606_sourcecode/Ch14/Listing 14-44.cs new file mode 100644 index 0000000..255cc82 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-44.cs @@ -0,0 +1,29 @@ +//using System; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// Task combinedResult = TestDelayWithWhenAny(); + +// while (true) +// { +// if (combinedResult.IsCompleted) +// { +// Console.WriteLine("Finished waiting"); +// break; +// } +// Console.Write("."); +// } +// Console.ReadLine(); +// } + +// public static async Task TestDelayWithWhenAny() +// { +// await Task.WhenAny(Task.Delay(1), Task.Delay(2000)); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-6.cs b/9781430248606_sourcecode/Ch14/Listing 14-6.cs new file mode 100644 index 0000000..30b092a --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-6.cs @@ -0,0 +1,18 @@ +//using System; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// Task displayTask = new Task( +// () => "async in C# 5.0", TaskCreationOptions.None); +// displayTask.Start(); +// Console.WriteLine("Result from the Task : {0}", +// displayTask.Result); +// Console.ReadLine(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-8.cs b/9781430248606_sourcecode/Ch14/Listing 14-8.cs new file mode 100644 index 0000000..c5f1849 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-8.cs @@ -0,0 +1,28 @@ +//using System; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// Task displayTask = Task.Run(() => +// { +// /* To simulate as doing something.*/ +// for (int i = 0; i <= Int16.MaxValue; ++i) ; +// return "async in C# 5.0"; +// }); +// Console.WriteLine("Result from the Task : {0}", +// displayTask.Result); + +// if (displayTask.IsCompleted) +// Console.Write(TaskStatus.RanToCompletion.ToString()); +// if (displayTask.IsCanceled) +// Console.Write(TaskStatus.Canceled.ToString()); +// if (displayTask.IsFaulted) +// Console.Write(TaskStatus.Faulted.ToString()); +// Console.ReadLine(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Listing 14-9.cs b/9781430248606_sourcecode/Ch14/Listing 14-9.cs new file mode 100644 index 0000000..ca5066f --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Listing 14-9.cs @@ -0,0 +1,27 @@ +//using System; +//using System.Threading.Tasks; + +//namespace Ch14 +//{ +// class Program +// { +// static void Main() +// { +// Task displayTask = Task.Run(() => +// { +// Task.Delay(500000); +// for (int i = 0; i < byte.MaxValue; ++i) ; +// Console.WriteLine("async in C# 5.0"); +// }); + +// while (true) +// { +// Console.WriteLine(displayTask.Status.ToString()); +// if (displayTask.IsCompleted) +// break; +// } +// Console.WriteLine(displayTask.Status.ToString()); +// Console.ReadLine(); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch14/Program.cs b/9781430248606_sourcecode/Ch14/Program.cs new file mode 100644 index 0000000..76c1853 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Program.cs @@ -0,0 +1,29 @@ +using System; +using System.Diagnostics; +using System.Threading; + +namespace Ch14 +{ + class Program + { + static void Main() + { + Stopwatch stopwatch = new Stopwatch(); + stopwatch.Start(); + Method1(); + Method2(); + Method3(); + Method4(); + Method5(); + stopwatch.Stop(); + Console.WriteLine("Elapsed time: {0}ms", + stopwatch.ElapsedMilliseconds); + Console.ReadKey(); + } + static void Method1() { Thread.Sleep(10); } + static void Method2() { Thread.Sleep(10); } + static void Method3() { Thread.Sleep(10); } + static void Method4() { Thread.Sleep(10); } + static void Method5() { Thread.Sleep(10); } + } +} diff --git a/9781430248606_sourcecode/Ch14/Properties/AssemblyInfo.cs b/9781430248606_sourcecode/Ch14/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..dea54fc --- /dev/null +++ b/9781430248606_sourcecode/Ch14/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ch14")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ch14")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a1e50cb2-7b98-4fc9-8752-cde13646e8d5")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9781430248606_sourcecode/Ch14/app.config b/9781430248606_sourcecode/Ch14/app.config new file mode 100644 index 0000000..c5e1dae --- /dev/null +++ b/9781430248606_sourcecode/Ch14/app.config @@ -0,0 +1,3 @@ + + + diff --git a/9781430248606_sourcecode/Ch14/bin/Release/Ch14.exe b/9781430248606_sourcecode/Ch14/bin/Release/Ch14.exe new file mode 100644 index 0000000..3512e9e Binary files /dev/null and b/9781430248606_sourcecode/Ch14/bin/Release/Ch14.exe differ diff --git a/9781430248606_sourcecode/Ch14/bin/Release/Ch14.pdb b/9781430248606_sourcecode/Ch14/bin/Release/Ch14.pdb new file mode 100644 index 0000000..13b56b9 Binary files /dev/null and b/9781430248606_sourcecode/Ch14/bin/Release/Ch14.pdb differ diff --git a/9781430248606_sourcecode/Ch14/obj/x86/Debug/Ch14.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch14/obj/x86/Debug/Ch14.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..da41b77 --- /dev/null +++ b/9781430248606_sourcecode/Ch14/obj/x86/Debug/Ch14.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch14\bin\Debug\Ch14.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch14\bin\Debug\Ch14.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch14\bin\Debug\Ch14.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch14\obj\x86\Debug\Ch14.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch14\obj\x86\Debug\Ch14.pdb diff --git a/9781430248606_sourcecode/Ch14/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch14/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..fbd0808 Binary files /dev/null and b/9781430248606_sourcecode/Ch14/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch14/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/9781430248606_sourcecode/Ch14/obj/x86/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch14/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/9781430248606_sourcecode/Ch14/obj/x86/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch14/obj/x86/Release/Ch14.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch14/obj/x86/Release/Ch14.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..3efc6ce --- /dev/null +++ b/9781430248606_sourcecode/Ch14/obj/x86/Release/Ch14.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch14\bin\Release\Ch14.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch14\bin\Release\Ch14.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch14\obj\x86\Release\ResolveAssemblyReference.cache +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch14\obj\x86\Release\Ch14.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch14\obj\x86\Release\Ch14.pdb diff --git a/9781430248606_sourcecode/Ch14/obj/x86/Release/Ch14.exe b/9781430248606_sourcecode/Ch14/obj/x86/Release/Ch14.exe new file mode 100644 index 0000000..3512e9e Binary files /dev/null and b/9781430248606_sourcecode/Ch14/obj/x86/Release/Ch14.exe differ diff --git a/9781430248606_sourcecode/Ch14/obj/x86/Release/Ch14.pdb b/9781430248606_sourcecode/Ch14/obj/x86/Release/Ch14.pdb new file mode 100644 index 0000000..13b56b9 Binary files /dev/null and b/9781430248606_sourcecode/Ch14/obj/x86/Release/Ch14.pdb differ diff --git a/9781430248606_sourcecode/Ch14/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch14/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..146263e Binary files /dev/null and b/9781430248606_sourcecode/Ch14/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch15/App.config b/9781430248606_sourcecode/Ch15/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/9781430248606_sourcecode/Ch15/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch15/Ch15.csproj b/9781430248606_sourcecode/Ch15/Ch15.csproj new file mode 100644 index 0000000..5e09994 --- /dev/null +++ b/9781430248606_sourcecode/Ch15/Ch15.csproj @@ -0,0 +1,62 @@ + + + + + Debug + AnyCPU + {36B857F9-F732-40C5-A582-95FEB9F485B0} + Exe + Properties + Ch15 + Ch15 + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch15/Listing 15-1.cs b/9781430248606_sourcecode/Ch15/Listing 15-1.cs new file mode 100644 index 0000000..af4c893 --- /dev/null +++ b/9781430248606_sourcecode/Ch15/Listing 15-1.cs @@ -0,0 +1,25 @@ +//using System; + +//namespace Ch15 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// Person aPerson = new Person() +// { +// Name = "A" +// }; +// aPerson.ShowDetails(); +// } +// } + +// public class Person +// { +// public string Name { get; set; } +// public void ShowDetails() +// { +// Console.WriteLine(Name); +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch15/Listing 15-2.cs b/9781430248606_sourcecode/Ch15/Listing 15-2.cs new file mode 100644 index 0000000..b9cb327 --- /dev/null +++ b/9781430248606_sourcecode/Ch15/Listing 15-2.cs @@ -0,0 +1,20 @@ +//using System; + +//namespace Ch15 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// try +// { +// int a = 100, b = 0; +// Console.WriteLine(a / b); +// } +// catch (DivideByZeroException dbze) +// { +// Console.WriteLine(dbze.Message); +// } +// } +// } +//} \ No newline at end of file diff --git a/9781430248606_sourcecode/Ch15/Listing 15-3.cs b/9781430248606_sourcecode/Ch15/Listing 15-3.cs new file mode 100644 index 0000000..0e3ccab --- /dev/null +++ b/9781430248606_sourcecode/Ch15/Listing 15-3.cs @@ -0,0 +1,17 @@ +//namespace Ch15 +//{ +// class Program +// { +// static void Main(string[] args) { } +// } + +// public class Universe +// { +// static double ageOfTheUniverse; +// public Universe() { } /* Compiled as .ctor */ +// public Universe(double age) { } /* Compiled as .ctor */ +// static Universe() +// { ageOfTheUniverse = 13.75e+10; } /* Compiled as .cctor */ +// public void EmtpyMethod() { } /* Method declaration */ +// } +//} diff --git a/9781430248606_sourcecode/Ch15/Listing 15-5.cs b/9781430248606_sourcecode/Ch15/Listing 15-5.cs new file mode 100644 index 0000000..7e5fb32 --- /dev/null +++ b/9781430248606_sourcecode/Ch15/Listing 15-5.cs @@ -0,0 +1,13 @@ +//using System; +//namespace Ch15 +//{ +// class Program +// { +// static void Main(string[] args) +// { +// double result = default(double); +// for (int i = 0; i < Int16.MaxValue; ++i) +// result += i; +// } +// } +//} diff --git a/9781430248606_sourcecode/Ch15/Program.cs b/9781430248606_sourcecode/Ch15/Program.cs new file mode 100644 index 0000000..6e21dce --- /dev/null +++ b/9781430248606_sourcecode/Ch15/Program.cs @@ -0,0 +1,25 @@ +using System; + +namespace Ch15 +{ + class Program + { + static void Main(string[] args) + { + Person aPerson = new Person() + { + Name = "A" + }; + aPerson.ShowDetails(); + } + } + + public class Person + { + public string Name { get; set; } + public void ShowDetails() + { + Console.WriteLine(Name); + } + } +} diff --git a/9781430248606_sourcecode/Ch15/Properties/AssemblyInfo.cs b/9781430248606_sourcecode/Ch15/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b8fa8b0 --- /dev/null +++ b/9781430248606_sourcecode/Ch15/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Ch15")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ch15")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9a4261f2-c344-4024-8157-31a6f7280012")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/9781430248606_sourcecode/Ch15/obj/Debug/Ch15.csproj.FileListAbsolute.txt b/9781430248606_sourcecode/Ch15/obj/Debug/Ch15.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..448f816 --- /dev/null +++ b/9781430248606_sourcecode/Ch15/obj/Debug/Ch15.csproj.FileListAbsolute.txt @@ -0,0 +1,5 @@ +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch15\bin\Debug\Ch15.exe.config +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch15\bin\Debug\Ch15.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch15\bin\Debug\Ch15.pdb +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch15\obj\Debug\Ch15.exe +J:\Book\ExpertC#2012\SourceCode\BookExamples\Ch15\obj\Debug\Ch15.pdb diff --git a/9781430248606_sourcecode/Ch15/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/9781430248606_sourcecode/Ch15/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..1e1558a Binary files /dev/null and b/9781430248606_sourcecode/Ch15/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/9781430248606_sourcecode/Ch15/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/9781430248606_sourcecode/Ch15/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/9781430248606_sourcecode/Ch15/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/9781430248606_sourcecode/Ch15/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..d463f39 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,27 @@ +Freeware License, some rights reserved + +Copyright (c) 2013 Mohammad Rahman + +Permission is hereby granted, free of charge, to anyone obtaining a copy +of this software and associated documentation files (the "Software"), +to work with the Software within the limits of freeware distribution and fair use. +This includes the rights to use, copy, and modify the Software for personal use. +Users are also allowed and encouraged to submit corrections and modifications +to the Software for the benefit of other users. + +It is not allowed to reuse, modify, or redistribute the Software for +commercial use in any way, or for a user’s educational materials such as books +or blog articles without prior permission from the copyright holder. + +The above copyright notice and this permission notice need to be included +in all copies or substantial portions of the software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..9d8dccb --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +#Apress Source Code + +This repository accompanies [*Expert C# 5.0*](http://www.apress.com/9781430248606) by Mohammad Rahman (Apress, 2013). + +![Cover image](9781430248606.jpg) + +Download the files as a zip using the green button, or clone the repository to your machine using Git. + +##Releases + +Release v1.0 corresponds to the code in the published book, without corrections or updates. + +##Contributions + +See the file Contributing.md for more information on how you can contribute to this repository. diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..f6005ad --- /dev/null +++ b/contributing.md @@ -0,0 +1,14 @@ +# Contributing to Apress Source Code + +Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. + +## How to Contribute + +1. Make sure you have a GitHub account. +2. Fork the repository for the relevant book. +3. Create a new branch on which to make your change, e.g. +`git checkout -b my_code_contribution` +4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. +5. Submit a pull request. + +Thank you for your contribution! \ No newline at end of file