Skip to content

Commit 2e2982e

Browse files
Matthew CarrollMatthew Carroll
Matthew Carroll
authored and
Matthew Carroll
committedMay 12, 2016
First commit
1 parent 187518c commit 2e2982e

33 files changed

+1122
-0
lines changed
 

‎CommonDataTypes/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>
+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{F3717210-6158-4368-96BF-9C10EED5698B}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>CommonDataTypes</RootNamespace>
11+
<AssemblyName>CommonDataTypes</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="ConsoleExercises.cs" />
47+
<Compile Include="DateTimeExercises.cs" />
48+
<Compile Include="EnvironmentExercises.cs" />
49+
<Compile Include="MathExercises.cs" />
50+
<Compile Include="Program.cs" />
51+
<Compile Include="Properties\AssemblyInfo.cs" />
52+
<Compile Include="StringBuilderExercises.cs" />
53+
<Compile Include="StringExercises.cs" />
54+
</ItemGroup>
55+
<ItemGroup>
56+
<None Include="App.config" />
57+
</ItemGroup>
58+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
59+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
60+
Other similar extension points exist, see Microsoft.Common.targets.
61+
<Target Name="BeforeBuild">
62+
</Target>
63+
<Target Name="AfterBuild">
64+
</Target>
65+
-->
66+
</Project>

‎CommonDataTypes/ConsoleExercises.cs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
3+
namespace CommonDataTypes
4+
{
5+
class ConsoleExercises
6+
{
7+
public static void RunExercises()
8+
{
9+
// Do the following:
10+
// 1. Print "Cub Scouts are awesome!" with a background color of blue and a foreground color of yellow
11+
// 2. Reset the console colors
12+
// 3. Set the title of the console to "Console Exercises"
13+
// 4. Using a format string, output the console width and height (e.g., "Width: 50 -- Height: 20")
14+
// 5. Print the following, using a loop for the number sequence:
15+
// Here are the numbers from 1 to 10
16+
// 1 2 3 4 5 6 7 8 9 10
17+
// Thank you!
18+
}
19+
}
20+
}

‎CommonDataTypes/DateTimeExercises.cs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
3+
namespace CommonDataTypes
4+
{
5+
static class DateTimeExercises
6+
{
7+
public static void RunExercises()
8+
{
9+
// Do the following:
10+
// 1. Initialize a DateTime object to July 20, 1969 at 8:18 PM UTC
11+
// 2. Output the day of the week for that date
12+
// 3. Output the date/time
13+
// 4. Output the date/time six hours and 38 minutes later
14+
// 5. Output the local date/time for the original date
15+
// 6. Output the number of days in February 2000
16+
// 7. Output the current date
17+
// 8. Output the current date/time
18+
// 9. Output the current day of the year
19+
// 10. Loop through all the years of the current decade and display the year and whether or not it's a leap year
20+
// 11. Output the range of valid date/time values (min to max)
21+
// 12. Output the current date/time with this format: yyyy-MM-dd HH:mm:ss
22+
// 13. Play with more format options: https://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
23+
}
24+
}
25+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
3+
namespace CommonDataTypes
4+
{
5+
static class EnvironmentExercises
6+
{
7+
public static void RunExercises()
8+
{
9+
// Do the following:
10+
// 1. Output the current directory
11+
// 2. Output the NetBIOS name of your computer
12+
// 3. Output your computer's operating system version information
13+
// 4. Output the number of processors in your computer
14+
// 5. Output the current stack trace
15+
// 6. Output the current user's login info: Domain\Username
16+
// 7. Output the directory of your user profile (hint: USERPROFILE)
17+
}
18+
}
19+
}

‎CommonDataTypes/MathExercises.cs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
3+
namespace CommonDataTypes
4+
{
5+
static class MathExercises
6+
{
7+
public static void RunExercises()
8+
{
9+
// Do the following:
10+
// 1. Output the value of PI
11+
// 2. Output the absolute value of your age minus the current year (use DateTime properties to get the year)
12+
// 3. Output 5.234 rounded up to the next integer value
13+
// 4. Output 5.675 rounded down to the previous integer value
14+
// 5. Output 5.234 rounded to the nearest integer value
15+
// 6. Output 2 to the 10th power
16+
// 7. Output the square root of 2016
17+
}
18+
}
19+
}

‎CommonDataTypes/Program.cs

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
3+
namespace CommonDataTypes
4+
{
5+
class Program
6+
{
7+
static void Main( string[] args )
8+
{
9+
Console.WriteLine( "Which exercise would you like to run:" );
10+
Console.WriteLine( " 1) Console exercises" );
11+
Console.WriteLine( " 2) String exercises" );
12+
Console.WriteLine( " 3) StringBuilder exercises" );
13+
Console.WriteLine( " 4) DateTime exercises" );
14+
Console.WriteLine( " 5) Environment exercises" );
15+
Console.WriteLine( " 6) Math exercises" );
16+
string choice = Console.ReadLine();
17+
Console.WriteLine();
18+
19+
switch ( choice )
20+
{
21+
case "1":
22+
ConsoleExercises.RunExercises();
23+
break;
24+
case "2":
25+
StringExercises.RunExercises();
26+
break;
27+
case "3":
28+
StringBuilderExercises.RunExercise();
29+
break;
30+
case "4":
31+
DateTimeExercises.RunExercises();
32+
break;
33+
case "5":
34+
EnvironmentExercises.RunExercises();
35+
break;
36+
case "6":
37+
MathExercises.RunExercises();
38+
break;
39+
default:
40+
Console.WriteLine( "Invalid option" );
41+
break;
42+
}
43+
44+
Console.Read();
45+
}
46+
}
47+
}
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle( "CommonDataTypes" )]
9+
[assembly: AssemblyDescription( "" )]
10+
[assembly: AssemblyConfiguration( "" )]
11+
[assembly: AssemblyCompany( "Microsoft" )]
12+
[assembly: AssemblyProduct( "CommonDataTypes" )]
13+
[assembly: AssemblyCopyright( "Copyright © Microsoft 2016" )]
14+
[assembly: AssemblyTrademark( "" )]
15+
[assembly: AssemblyCulture( "" )]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible( false )]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid( "f3717210-6158-4368-96bf-9c10eed5698b" )]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion( "1.0.0.0" )]
36+
[assembly: AssemblyFileVersion( "1.0.0.0" )]
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Text;
3+
4+
namespace CommonDataTypes
5+
{
6+
static class StringBuilderExercises
7+
{
8+
public static void RunExercise()
9+
{
10+
// Do the following:
11+
// 1. Add a line that says "Here are the numbers from 1 to 10"
12+
// 2. Add a line that says "1 2 3 4 5 6 7 8 9 10 " using a loop for the number sequence
13+
// 3. Add a line that says "Thank you!"
14+
// 4. Add a formatted line (with no line break at the end) that shows the length of the string before adding this line
15+
// 5. Output the string
16+
17+
StringBuilder myString = new StringBuilder();
18+
}
19+
}
20+
}

‎CommonDataTypes/StringExercises.cs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
3+
namespace CommonDataTypes
4+
{
5+
static class StringExercises
6+
{
7+
public static void RunExercises()
8+
{
9+
// Do the following:
10+
// 1. Output the length of the string
11+
// 2. Output whether or not the string contains the word "ark"
12+
// 3. Format a new string variable using the following: 8 character sub string starting at the
13+
// 40th character, first 5 characters, last 8 characters
14+
// 4. Output the new string
15+
// 5. Output the original string in all uppercase letters
16+
// 6. Output the original string in all lowercase letters
17+
// 7. Output the original string, but replace "Powerful" with "Weak"
18+
// 8. Output the original string with all spaces changed to hyphens by splitting and joining the string
19+
20+
string yoda = "Powerful you have become, the dark side I sense in you.";
21+
}
22+
}
23+
}

‎DataTypes.sln

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25123.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ValueVsReferenceTypes", "ValueVsReferenceTypes\ValueVsReferenceTypes.csproj", "{7BF34B29-99AF-4ACD-9A64-9091D9000284}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrimitiveTypes", "PrimitiveTypes\PrimitiveTypes.csproj", "{42CA8FB4-07D6-4637-B916-1702586DC439}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Enums", "Enums\Enums.csproj", "{AE968406-A01C-43E3-B647-DCA3FFF313B4}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommonDataTypes", "CommonDataTypes\CommonDataTypes.csproj", "{F3717210-6158-4368-96BF-9C10EED5698B}"
13+
EndProject
14+
Global
15+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
16+
Debug|Any CPU = Debug|Any CPU
17+
Release|Any CPU = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20+
{7BF34B29-99AF-4ACD-9A64-9091D9000284}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{7BF34B29-99AF-4ACD-9A64-9091D9000284}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{7BF34B29-99AF-4ACD-9A64-9091D9000284}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{7BF34B29-99AF-4ACD-9A64-9091D9000284}.Release|Any CPU.Build.0 = Release|Any CPU
24+
{42CA8FB4-07D6-4637-B916-1702586DC439}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25+
{42CA8FB4-07D6-4637-B916-1702586DC439}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{42CA8FB4-07D6-4637-B916-1702586DC439}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{42CA8FB4-07D6-4637-B916-1702586DC439}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{AE968406-A01C-43E3-B647-DCA3FFF313B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{AE968406-A01C-43E3-B647-DCA3FFF313B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{AE968406-A01C-43E3-B647-DCA3FFF313B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{AE968406-A01C-43E3-B647-DCA3FFF313B4}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{F3717210-6158-4368-96BF-9C10EED5698B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33+
{F3717210-6158-4368-96BF-9C10EED5698B}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{F3717210-6158-4368-96BF-9C10EED5698B}.Release|Any CPU.ActiveCfg = Release|Any CPU
35+
{F3717210-6158-4368-96BF-9C10EED5698B}.Release|Any CPU.Build.0 = Release|Any CPU
36+
EndGlobalSection
37+
GlobalSection(SolutionProperties) = preSolution
38+
HideSolutionNode = FALSE
39+
EndGlobalSection
40+
EndGlobal

‎Enums/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>

‎Enums/Colors.cs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
3+
namespace Enums
4+
{
5+
static class Colors
6+
{
7+
public static void RunExample()
8+
{
9+
Console.WriteLine( "This is the default color" );
10+
Console.ForegroundColor = (ConsoleColor)11;
11+
Console.WriteLine( "I don't know what color this will be" );
12+
Console.ForegroundColor = (ConsoleColor)14;
13+
Console.WriteLine( "I don't know what color this will be, either" );
14+
15+
Console.ForegroundColor = ConsoleColor.Green;
16+
Console.WriteLine( "I know this will be green. It's value is: {0}", (int)ConsoleColor.Green );
17+
}
18+
}
19+
}

‎Enums/Direction.cs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace Enums
2+
{
3+
enum Direction
4+
{
5+
North = 0,
6+
NorthEast = 45,
7+
East = 90,
8+
SouthEast = 135,
9+
South = 180,
10+
SouthWest = 225,
11+
West = 270,
12+
NorthWest = 315
13+
}
14+
}

‎Enums/EnumMethods.cs

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
using System;
2+
using System.Linq;
3+
4+
namespace Enums
5+
{
6+
static class EnumMethods
7+
{
8+
public static void RunExample()
9+
{
10+
// Enum.GetNames
11+
Console.WriteLine( "The names in Direction are:" );
12+
foreach ( string name in Enum.GetNames( typeof( Direction ) ) )
13+
{
14+
Console.WriteLine( " {0}", name );
15+
}
16+
Console.WriteLine();
17+
Console.ReadLine();
18+
19+
// Enum.GetValues
20+
Console.WriteLine( "The values in Direction are:" );
21+
Enum.GetValues( typeof( Direction ) ).Cast<int>().ToList().ForEach( val => Console.WriteLine( " {0}", val ) );
22+
Console.WriteLine();
23+
Console.ReadLine();
24+
25+
// Enum.IsDefined
26+
Console.WriteLine( "Check if values are in the enum" );
27+
Console.WriteLine( " 5 {0} in the enum", CheckInEnum( 5 ) );
28+
Console.WriteLine( " 45 {0} in the enum", CheckInEnum( 45 ) );
29+
Console.WriteLine( " North {0} in the enum", CheckInEnum( "North" ) );
30+
Console.WriteLine( " NorthNorthEast {0} in the enum", CheckInEnum( "NorthNorthEast" ) );
31+
Console.WriteLine();
32+
Console.ReadLine();
33+
34+
// Enum.Parse
35+
Direction value;
36+
try
37+
{
38+
Console.WriteLine( "Parse West" );
39+
value = (Direction)Enum.Parse( typeof( Direction ), "West" );
40+
Console.WriteLine( " Parse Succeeded: {0}", value );
41+
}
42+
catch
43+
{
44+
Console.WriteLine( " Parse failed" );
45+
}
46+
try
47+
{
48+
Console.WriteLine( "Parse 180" );
49+
value = (Direction)Enum.Parse( typeof( Direction ), "180" );
50+
Console.WriteLine( " Parse Succeeded: {0}", value );
51+
}
52+
catch
53+
{
54+
Console.WriteLine( " Parse failed" );
55+
}
56+
try
57+
{
58+
Console.WriteLine( "Parse Sur" );
59+
value = (Direction)Enum.Parse( typeof( Direction ), "Sur" );
60+
Console.WriteLine( " Parse Succeeded: {0}", value );
61+
}
62+
catch
63+
{
64+
Console.WriteLine( " Parse failed" );
65+
}
66+
Console.ReadLine();
67+
68+
// Enum.TryParse
69+
Console.WriteLine( "TryParse West" );
70+
if (Enum.TryParse<Direction>("West", out value))
71+
{
72+
Console.WriteLine( " TryParse Succeeded: {0}", value );
73+
}
74+
else
75+
{
76+
Console.WriteLine( " Parse failed" );
77+
}
78+
Console.WriteLine( "TryParse 180" );
79+
if ( Enum.TryParse<Direction>( "180", out value ) )
80+
{
81+
Console.WriteLine( " TryParse Succeeded: {0}", value );
82+
}
83+
else
84+
{
85+
Console.WriteLine( "TryParse failed" );
86+
}
87+
Console.WriteLine( "TryParse Sur" );
88+
if ( Enum.TryParse<Direction>( "Sur", out value ) )
89+
{
90+
Console.WriteLine( " TryParse Succeeded: {0}", value );
91+
}
92+
else
93+
{
94+
Console.WriteLine( " TryParse failed" );
95+
}
96+
}
97+
98+
static string CheckInEnum(object value)
99+
{
100+
if ( Enum.IsDefined( typeof( Direction ), value ) )
101+
{
102+
return "is";
103+
}
104+
else
105+
{
106+
return "is not";
107+
}
108+
}
109+
}
110+
}

‎Enums/Enums.csproj

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{AE968406-A01C-43E3-B647-DCA3FFF313B4}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Enums</RootNamespace>
11+
<AssemblyName>Enums</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Colors.cs" />
47+
<Compile Include="EnumMethods.cs" />
48+
<Compile Include="Headings.cs" />
49+
<Compile Include="Direction.cs" />
50+
<Compile Include="Program.cs" />
51+
<Compile Include="Properties\AssemblyInfo.cs" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<None Include="App.config" />
55+
</ItemGroup>
56+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
57+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
58+
Other similar extension points exist, see Microsoft.Common.targets.
59+
<Target Name="BeforeBuild">
60+
</Target>
61+
<Target Name="AfterBuild">
62+
</Target>
63+
-->
64+
</Project>

‎Enums/Headings.cs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
3+
namespace Enums
4+
{
5+
static class Headings
6+
{
7+
public static void RunExample()
8+
{
9+
// Complete the output for any four of the values in the Direction enum
10+
// The first value should be the name of the enum value
11+
// The second value should be the value of the enum value
12+
13+
Console.WriteLine( "The heading for {0} is: {1} degrees" );
14+
Console.WriteLine( "The heading for {0} is: {1} degrees" );
15+
Console.WriteLine( "The heading for {0} is: {1} degrees" );
16+
Console.WriteLine( "The heading for {0} is: {1} degrees" );
17+
}
18+
}
19+
}

‎Enums/Program.cs

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using System;
2+
3+
namespace Enums
4+
{
5+
class Program
6+
{
7+
static void Main( string[] args )
8+
{
9+
Console.WriteLine( "Which example would you like to run:" );
10+
Console.WriteLine( " 0) Colors" );
11+
Console.WriteLine( " 1) Headings" );
12+
Console.WriteLine( " 2) EnumMethods" );
13+
14+
MenuChoice choice;
15+
if ( !Enum.TryParse<MenuChoice>( Console.ReadLine(), out choice ) )
16+
{
17+
Console.WriteLine( "Invalid option" );
18+
}
19+
else
20+
{
21+
Console.WriteLine();
22+
23+
switch ( choice )
24+
{
25+
case MenuChoice.Colors:
26+
Colors.RunExample();
27+
break;
28+
case MenuChoice.Headings:
29+
Headings.RunExample();
30+
break;
31+
case MenuChoice.EnumMethods:
32+
EnumMethods.RunExample();
33+
break;
34+
default:
35+
Console.WriteLine( "Invalid option" );
36+
break;
37+
}
38+
}
39+
40+
Console.Read();
41+
}
42+
}
43+
44+
enum MenuChoice
45+
{
46+
Colors, // Value defaults to 0
47+
Headings, // Value defaults to 1
48+
EnumMethods // Value defaults to 2
49+
}
50+
}

‎Enums/Properties/AssemblyInfo.cs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle( "Enums" )]
9+
[assembly: AssemblyDescription( "" )]
10+
[assembly: AssemblyConfiguration( "" )]
11+
[assembly: AssemblyCompany( "Microsoft" )]
12+
[assembly: AssemblyProduct( "Enums" )]
13+
[assembly: AssemblyCopyright( "Copyright © Microsoft 2016" )]
14+
[assembly: AssemblyTrademark( "" )]
15+
[assembly: AssemblyCulture( "" )]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible( false )]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid( "ae968406-a01c-43e3-b647-dca3fff313b4" )]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion( "1.0.0.0" )]
36+
[assembly: AssemblyFileVersion( "1.0.0.0" )]

‎PrimitiveTypes/Aliases.cs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
3+
namespace PrimitiveTypes
4+
{
5+
static class Aliases
6+
{
7+
public static void RunExample()
8+
{
9+
byte byteTest = 1;
10+
sbyte sbyteTest = 1;
11+
int intTest = 1;
12+
uint uintTest = 1;
13+
short shortTest = 1;
14+
ushort ushortTest = 1;
15+
long longTest = 1;
16+
ulong ulongTest = 1;
17+
float floatTest = 1;
18+
double doubleTest = 1;
19+
decimal decimalTest = 1;
20+
char charTest = '1';
21+
bool boolTest = true;
22+
23+
Console.WriteLine( "byte {0} a Byte", byteTest is Byte ? "is" : "is not" );
24+
Console.WriteLine( "sbyte {0} a SByte", sbyteTest is SByte ? "is" : "is not" );
25+
Console.WriteLine( "int {0} a Int32", intTest is Int32 ? "is" : "is not" );
26+
Console.WriteLine( "uint {0} a UInt32", uintTest is UInt32 ? "is" : "is not" );
27+
Console.WriteLine( "short {0} a Int16", shortTest is Int16 ? "is" : "is not" );
28+
Console.WriteLine( "ushort {0} a UInt16", ushortTest is UInt16 ? "is" : "is not" );
29+
Console.WriteLine( "long {0} a Int64", longTest is Int64 ? "is" : "is not" );
30+
Console.WriteLine( "ulong {0} a UInt64", ulongTest is UInt64 ? "is" : "is not" );
31+
Console.WriteLine( "float {0} a Single", floatTest is Single ? "is" : "is not" );
32+
Console.WriteLine( "double {0} a Double", doubleTest is Double ? "is" : "is not" );
33+
Console.WriteLine( "decimal {0} a Decimal", decimalTest is Decimal ? "is" : "is not" );
34+
Console.WriteLine( "char {0} a Char", charTest is Char ? "is" : "is not" );
35+
Console.WriteLine( "bool {0} a Boolean", boolTest is Boolean ? "is" : "is not" );
36+
37+
Console.WriteLine( "int {0} a Int64", intTest is Int64 ? "is" : "is not" );
38+
}
39+
}
40+
}

‎PrimitiveTypes/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>

‎PrimitiveTypes/PrimitiveTypes.csproj

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{42CA8FB4-07D6-4637-B916-1702586DC439}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>PrimitiveTypes</RootNamespace>
11+
<AssemblyName>PrimitiveTypes</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="SizeAndRange.cs" />
47+
<Compile Include="Program.cs" />
48+
<Compile Include="Properties\AssemblyInfo.cs" />
49+
<Compile Include="Aliases.cs" />
50+
</ItemGroup>
51+
<ItemGroup>
52+
<None Include="App.config" />
53+
</ItemGroup>
54+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
55+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
56+
Other similar extension points exist, see Microsoft.Common.targets.
57+
<Target Name="BeforeBuild">
58+
</Target>
59+
<Target Name="AfterBuild">
60+
</Target>
61+
-->
62+
</Project>

‎PrimitiveTypes/Program.cs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
3+
namespace PrimitiveTypes
4+
{
5+
class Program
6+
{
7+
static void Main( string[] args )
8+
{
9+
Console.WriteLine( "Which example would you like to run:" );
10+
Console.WriteLine( " 1) Aliases" );
11+
Console.WriteLine( " 2) Size and Range" );
12+
string choice = Console.ReadLine();
13+
Console.WriteLine();
14+
15+
switch ( choice )
16+
{
17+
case "1":
18+
Aliases.RunExample();
19+
break;
20+
case "2":
21+
SizeAndRange.RunExample();
22+
break;
23+
default:
24+
Console.WriteLine( "Invalid option" );
25+
break;
26+
}
27+
28+
Console.Read();
29+
}
30+
}
31+
}
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle( "PrimitiveTypes" )]
9+
[assembly: AssemblyDescription( "" )]
10+
[assembly: AssemblyConfiguration( "" )]
11+
[assembly: AssemblyCompany( "Microsoft" )]
12+
[assembly: AssemblyProduct( "PrimitiveTypes" )]
13+
[assembly: AssemblyCopyright( "Copyright © Microsoft 2016" )]
14+
[assembly: AssemblyTrademark( "" )]
15+
[assembly: AssemblyCulture( "" )]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible( false )]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid( "42ca8fb4-07d6-4637-b916-1702586dc439" )]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion( "1.0.0.0" )]
36+
[assembly: AssemblyFileVersion( "1.0.0.0" )]

‎PrimitiveTypes/SizeAndRange.cs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
3+
namespace PrimitiveTypes
4+
{
5+
static class SizeAndRange
6+
{
7+
public static void RunExample()
8+
{
9+
// Complete the output for the primitive types
10+
// Display the amount of memory (in bits) that the type uses
11+
// Display the valid range of values for the type
12+
13+
Console.WriteLine( "byte" );
14+
Console.WriteLine( " Size: {0}" );
15+
Console.WriteLine( " Range: {0} to {1}" );
16+
Console.WriteLine();
17+
18+
Console.WriteLine( "ulong" );
19+
Console.WriteLine( " Size: {0}" );
20+
Console.WriteLine( " Range: {0} to {1}" );
21+
Console.WriteLine();
22+
23+
Console.WriteLine( "float" );
24+
Console.WriteLine( " Size: {0}" );
25+
Console.WriteLine( " Range: {0} to {1}" );
26+
Console.WriteLine();
27+
28+
Console.WriteLine( "bool" );
29+
Console.WriteLine( " Size: {0}" );
30+
Console.WriteLine();
31+
}
32+
}
33+
}

‎ValueVsReferenceTypes/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>

‎ValueVsReferenceTypes/MyClass.cs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace ValueVsReferenceTypes
4+
{
5+
class MyClass
6+
{
7+
public int ClassIntValue;
8+
public string ClassStringValue;
9+
10+
public override string ToString()
11+
{
12+
return String.Format( "{0} - {1}", ClassIntValue, ClassStringValue );
13+
}
14+
}
15+
}

‎ValueVsReferenceTypes/MyStruct.cs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace ValueVsReferenceTypes
4+
{
5+
struct MyStruct
6+
{
7+
public int StructIntValue;
8+
public string StructStringValue;
9+
10+
public override string ToString()
11+
{
12+
return String.Format( "{0} - {1}", StructIntValue, StructStringValue );
13+
}
14+
}
15+
}
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
3+
namespace ValueVsReferenceTypes
4+
{
5+
static class ParameterPassing
6+
{
7+
public static void RunExample()
8+
{
9+
int intValue = 5;
10+
MyStruct structValue = new MyStruct
11+
{
12+
StructIntValue = 100,
13+
StructStringValue = "Struct Test"
14+
};
15+
MyClass classValue = new MyClass
16+
{
17+
ClassIntValue = 200,
18+
ClassStringValue = "Class Test"
19+
};
20+
21+
Console.WriteLine( "Values Before Method" );
22+
Console.WriteLine( "====================" );
23+
Console.WriteLine( "intValue: {0}", intValue );
24+
Console.WriteLine( "structValue: {0}", structValue );
25+
Console.WriteLine( "classValue: {0}", classValue );
26+
Console.WriteLine();
27+
Console.Read();
28+
29+
ChangeValues( intValue, structValue, classValue );
30+
Console.Read();
31+
32+
Console.WriteLine( "Values After Method" );
33+
Console.WriteLine( "===================" );
34+
Console.WriteLine( "intValue: {0}", intValue );
35+
Console.WriteLine( "structValue: {0}", structValue );
36+
Console.WriteLine( "classValue: {0}", classValue );
37+
}
38+
39+
static void ChangeValues( int intValue, MyStruct structValue, MyClass classValue )
40+
{
41+
intValue = 10;
42+
structValue.StructIntValue = 101;
43+
structValue.StructStringValue = "Struct Test 2";
44+
classValue.ClassIntValue = 201;
45+
classValue.ClassStringValue = "Class Test 2";
46+
47+
Console.WriteLine( "Values In Method" );
48+
Console.WriteLine( "================" );
49+
Console.WriteLine( "intValue: {0}", intValue );
50+
Console.WriteLine( "structValue: {0}", structValue );
51+
Console.WriteLine( "classValue: {0}", classValue );
52+
Console.WriteLine();
53+
}
54+
}
55+
}

‎ValueVsReferenceTypes/Program.cs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
3+
namespace ValueVsReferenceTypes
4+
{
5+
class Program
6+
{
7+
static void Main( string[] args )
8+
{
9+
Console.WriteLine( "Which example would you like to run:" );
10+
Console.WriteLine( " 1) Parameter passing" );
11+
Console.WriteLine( " 2) Variable assignment" );
12+
string choice = Console.ReadLine();
13+
Console.WriteLine();
14+
15+
switch(choice)
16+
{
17+
case "1":
18+
ParameterPassing.RunExample();
19+
break;
20+
case "2":
21+
VariableAssignment.RunExample();
22+
break;
23+
default:
24+
Console.WriteLine( "Invalid option" );
25+
break;
26+
}
27+
28+
Console.Read();
29+
}
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle( "DataTypes" )]
9+
[assembly: AssemblyDescription( "" )]
10+
[assembly: AssemblyConfiguration( "" )]
11+
[assembly: AssemblyCompany( "Microsoft" )]
12+
[assembly: AssemblyProduct( "DataTypes" )]
13+
[assembly: AssemblyCopyright( "Copyright © Microsoft 2016" )]
14+
[assembly: AssemblyTrademark( "" )]
15+
[assembly: AssemblyCulture( "" )]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible( false )]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid( "7bf34b29-99af-4acd-9a64-9091d9000284" )]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion( "1.0.0.0" )]
36+
[assembly: AssemblyFileVersion( "1.0.0.0" )]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{7BF34B29-99AF-4ACD-9A64-9091D9000284}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>ValueVsReferenceTypes</RootNamespace>
11+
<AssemblyName>ValueVsReferenceTypes</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="MyClass.cs" />
47+
<Compile Include="MyStruct.cs" />
48+
<Compile Include="VariableAssignment.cs" />
49+
<Compile Include="ParameterPassing.cs" />
50+
<Compile Include="Program.cs" />
51+
<Compile Include="Properties\AssemblyInfo.cs" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<None Include="App.config" />
55+
</ItemGroup>
56+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
57+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
58+
Other similar extension points exist, see Microsoft.Common.targets.
59+
<Target Name="BeforeBuild">
60+
</Target>
61+
<Target Name="AfterBuild">
62+
</Target>
63+
-->
64+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System;
2+
3+
namespace ValueVsReferenceTypes
4+
{
5+
static class VariableAssignment
6+
{
7+
public static void RunExample()
8+
{
9+
int intValue1 = 5;
10+
int intValue2 = intValue1;
11+
12+
MyStruct structValue1 = new MyStruct
13+
{
14+
StructIntValue = 100,
15+
StructStringValue = "Struct Test"
16+
};
17+
MyStruct structValue2 = structValue1;
18+
19+
MyClass classValue1 = new MyClass
20+
{
21+
ClassIntValue = 200,
22+
ClassStringValue = "Class Test"
23+
};
24+
MyClass classValue2 = classValue1;
25+
26+
Console.WriteLine( "Values Before Changes" );
27+
Console.WriteLine( "=====================" );
28+
Console.WriteLine( "intValue1: {0}", intValue1 );
29+
Console.WriteLine( "intValue2: {0}", intValue2 );
30+
Console.WriteLine( "structValue1: {0}", structValue1 );
31+
Console.WriteLine( "structValue2: {0}", structValue2 );
32+
Console.WriteLine( "classValue1: {0}", classValue1 );
33+
Console.WriteLine( "classValue2: {0}", classValue2 );
34+
Console.WriteLine();
35+
Console.Read();
36+
37+
intValue2 = 10;
38+
structValue2.StructIntValue = 101;
39+
structValue2.StructStringValue = "Struct Test 2";
40+
classValue2.ClassIntValue = 201;
41+
classValue2.ClassStringValue = "Class Test 2";
42+
43+
Console.WriteLine( "Values After Changes" );
44+
Console.WriteLine( "====================" );
45+
Console.WriteLine( "intValue1: {0}", intValue1 );
46+
Console.WriteLine( "intValue2: {0}", intValue2 );
47+
Console.WriteLine( "structValue1: {0}", structValue1 );
48+
Console.WriteLine( "structValue2: {0}", structValue2 );
49+
Console.WriteLine( "classValue1: {0}", classValue1 );
50+
Console.WriteLine( "classValue2: {0}", classValue2 );
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)
Please sign in to comment.