Second day
This commit is contained in:
6
Anonymous/Anonymous/App.config
Normal file
6
Anonymous/Anonymous/App.config
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
22
Excercise7/Excercise7.sln
Normal file
22
Excercise7/Excercise7.sln
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.31101.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Excercise7", "Excercise7\Excercise7.csproj", "{C8EAD11F-0F9E-46A8-AC8D-81C3E29E51A1}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{C8EAD11F-0F9E-46A8-AC8D-81C3E29E51A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C8EAD11F-0F9E-46A8-AC8D-81C3E29E51A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C8EAD11F-0F9E-46A8-AC8D-81C3E29E51A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C8EAD11F-0F9E-46A8-AC8D-81C3E29E51A1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
6
Excercise7/Excercise7/App.config
Normal file
6
Excercise7/Excercise7/App.config
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
60
Excercise7/Excercise7/Excercise7.csproj
Normal file
60
Excercise7/Excercise7/Excercise7.csproj
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{C8EAD11F-0F9E-46A8-AC8D-81C3E29E51A1}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Excercise7</RootNamespace>
|
||||||
|
<AssemblyName>Excercise7</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Weight.cs" />
|
||||||
|
<Compile Include="WeightUnit.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
43
Excercise7/Excercise7/Program.cs
Normal file
43
Excercise7/Excercise7/Program.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Exercise5;
|
||||||
|
|
||||||
|
namespace Excercise7
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
// wFirst and wSecond are Weight-instances
|
||||||
|
Weight wFirst = new Weight();
|
||||||
|
Weight wSecond = new Weight();
|
||||||
|
|
||||||
|
wFirst.SetWeight(WeightUnit.Kilogram, 50);
|
||||||
|
wSecond.SetWeight(WeightUnit.Kilogram, 60);
|
||||||
|
|
||||||
|
var first = wFirst.GetWeight(WeightUnit.Kilogram);
|
||||||
|
|
||||||
|
wSecond.Add(wFirst);
|
||||||
|
Console.WriteLine(wSecond.GetWeight(WeightUnit.Kilogram));
|
||||||
|
|
||||||
|
wSecond.SetWeight(wFirst);
|
||||||
|
Console.WriteLine(wSecond.GetWeight(WeightUnit.Kilogram));
|
||||||
|
|
||||||
|
var wResult = wFirst + wSecond;
|
||||||
|
Console.WriteLine(wResult.GetWeight(WeightUnit.Kilogram));
|
||||||
|
|
||||||
|
WaitForInput();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WaitForInput()
|
||||||
|
{
|
||||||
|
Console.WriteLine("\nPress enter...");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Excercise7/Excercise7/Properties/AssemblyInfo.cs
Normal file
36
Excercise7/Excercise7/Properties/AssemblyInfo.cs
Normal file
@@ -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("Excercise7")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Excercise7")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||||
|
[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("44aeb9fa-21aa-4249-87ab-2325924dca14")]
|
||||||
|
|
||||||
|
// 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")]
|
||||||
91
Excercise7/Excercise7/Weight.cs
Normal file
91
Excercise7/Excercise7/Weight.cs
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Exercise5
|
||||||
|
{
|
||||||
|
class Weight
|
||||||
|
{
|
||||||
|
private double weight = 0; // Nullable Type
|
||||||
|
|
||||||
|
public void SetWeight(WeightUnit weightUnit, double p)
|
||||||
|
{
|
||||||
|
switch (weightUnit)
|
||||||
|
{
|
||||||
|
case WeightUnit.Kilogram:
|
||||||
|
weight = p;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Pound:
|
||||||
|
weight = p * 0.45359237;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Gram:
|
||||||
|
weight = p / 1000;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Ounce:
|
||||||
|
weight = p * 0.0283495231;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(WeightUnit weightUnit, double p)
|
||||||
|
{
|
||||||
|
switch (weightUnit)
|
||||||
|
{
|
||||||
|
case WeightUnit.Kilogram:
|
||||||
|
weight += p;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Pound:
|
||||||
|
weight += p * 0.45359237;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Gram:
|
||||||
|
weight = p / 1000;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Ounce:
|
||||||
|
weight = p * 0.0283495231;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double GetWeight(WeightUnit weightUnit)
|
||||||
|
{
|
||||||
|
switch (weightUnit)
|
||||||
|
{
|
||||||
|
case WeightUnit.Kilogram:
|
||||||
|
return weight;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Pound:
|
||||||
|
return (weight*2.20462262);
|
||||||
|
break;
|
||||||
|
case WeightUnit.Gram:
|
||||||
|
return (weight * 1000);
|
||||||
|
break;
|
||||||
|
case WeightUnit.Ounce:
|
||||||
|
return (weight * 35.2739619);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new NotImplementedException();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(Weight w)
|
||||||
|
{
|
||||||
|
weight += w.GetWeight(WeightUnit.Kilogram);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetWeight(Weight w)
|
||||||
|
{
|
||||||
|
SetWeight(WeightUnit.Kilogram, w.GetWeight(WeightUnit.Kilogram));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Weight operator +(Weight leftWeight, Weight rightWeight)
|
||||||
|
{
|
||||||
|
Weight sumWeight = new Weight();
|
||||||
|
|
||||||
|
sumWeight.SetWeight(WeightUnit.Kilogram, leftWeight.GetWeight(WeightUnit.Kilogram) + rightWeight.GetWeight(WeightUnit.Kilogram));
|
||||||
|
|
||||||
|
return sumWeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
Excercise7/Excercise7/WeightUnit.cs
Normal file
16
Excercise7/Excercise7/WeightUnit.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Exercise5
|
||||||
|
{
|
||||||
|
|
||||||
|
public enum WeightUnit : long
|
||||||
|
{
|
||||||
|
Kilogram,
|
||||||
|
Gram,
|
||||||
|
Pound,
|
||||||
|
Ounce
|
||||||
|
}
|
||||||
|
}
|
||||||
22
Excersise2A/Excersise2A.sln
Normal file
22
Excersise2A/Excersise2A.sln
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.31101.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Excersise2A", "Excersise2A\Excersise2A.csproj", "{6685944B-FD6B-4C3D-82ED-7625749F08AF}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{6685944B-FD6B-4C3D-82ED-7625749F08AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6685944B-FD6B-4C3D-82ED-7625749F08AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6685944B-FD6B-4C3D-82ED-7625749F08AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6685944B-FD6B-4C3D-82ED-7625749F08AF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
6
Excersise2A/Excersise2A/App.config
Normal file
6
Excersise2A/Excersise2A/App.config
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
38
Excersise2A/Excersise2A/CustomStack.cs
Normal file
38
Excersise2A/Excersise2A/CustomStack.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Excersise2A
|
||||||
|
{
|
||||||
|
class CustomStack<T>
|
||||||
|
{
|
||||||
|
private List<T> items = new List<T>();
|
||||||
|
|
||||||
|
public T Peek()
|
||||||
|
{
|
||||||
|
T item = items[0];
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
public T Pop()
|
||||||
|
{
|
||||||
|
T item = items[0];
|
||||||
|
items.RemoveAt(0);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
public T Push(T item)
|
||||||
|
{
|
||||||
|
items.Insert(0, item);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool isEmpty()
|
||||||
|
{
|
||||||
|
if (items.Count == 0)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
59
Excersise2A/Excersise2A/Excersise2A.csproj
Normal file
59
Excersise2A/Excersise2A/Excersise2A.csproj
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{6685944B-FD6B-4C3D-82ED-7625749F08AF}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Excersise2A</RootNamespace>
|
||||||
|
<AssemblyName>Excersise2A</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="CustomStack.cs" />
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
44
Excersise2A/Excersise2A/Program.cs
Normal file
44
Excersise2A/Excersise2A/Program.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Excersise2A
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
CustomStack<int> intStack = new CustomStack<int>();
|
||||||
|
CustomStack<string> stringStack = new CustomStack<string>();
|
||||||
|
|
||||||
|
/* ------ INT-STACK --------------- */
|
||||||
|
intStack.Push(14);
|
||||||
|
intStack.Push(23);
|
||||||
|
intStack.Push(34);
|
||||||
|
intStack.Push(46);
|
||||||
|
Console.WriteLine(intStack.Peek());
|
||||||
|
|
||||||
|
intStack.Pop();
|
||||||
|
Console.WriteLine(intStack.Peek());
|
||||||
|
|
||||||
|
/* ------ STRING-STACK --------------- */
|
||||||
|
stringStack.Push("Anna");
|
||||||
|
stringStack.Push("Bertil");
|
||||||
|
stringStack.Push("Ceasar");
|
||||||
|
Console.WriteLine(stringStack.Peek());
|
||||||
|
|
||||||
|
stringStack.Pop();
|
||||||
|
Console.WriteLine(stringStack.Peek());
|
||||||
|
|
||||||
|
|
||||||
|
WaitForInput();
|
||||||
|
}
|
||||||
|
static void WaitForInput()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Press Enter...");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Excersise2A/Excersise2A/Properties/AssemblyInfo.cs
Normal file
36
Excersise2A/Excersise2A/Properties/AssemblyInfo.cs
Normal file
@@ -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("Excersise2A")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Excersise2A")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||||
|
[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("6591cb97-6bbf-48b1-8cac-18d0687aab66")]
|
||||||
|
|
||||||
|
// 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")]
|
||||||
22
Excersise3/Excersise3.sln
Normal file
22
Excersise3/Excersise3.sln
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.31101.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Excersise3", "Excersise3\Excersise3.csproj", "{E5508F12-33D7-48BC-B740-46E91846C506}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{E5508F12-33D7-48BC-B740-46E91846C506}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E5508F12-33D7-48BC-B740-46E91846C506}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E5508F12-33D7-48BC-B740-46E91846C506}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E5508F12-33D7-48BC-B740-46E91846C506}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
6
Excersise3/Excersise3/App.config
Normal file
6
Excersise3/Excersise3/App.config
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
59
Excersise3/Excersise3/Excersise3.csproj
Normal file
59
Excersise3/Excersise3/Excersise3.csproj
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{E5508F12-33D7-48BC-B740-46E91846C506}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Excersise3</RootNamespace>
|
||||||
|
<AssemblyName>Excersise3</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="ListLoader.cs" />
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
23
Excersise3/Excersise3/ListLoader.cs
Normal file
23
Excersise3/Excersise3/ListLoader.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace Excersise3
|
||||||
|
{
|
||||||
|
public class ListLoader
|
||||||
|
{
|
||||||
|
public List<string> LoadListFromFile(string fileName)
|
||||||
|
{
|
||||||
|
var list = new List<string>();
|
||||||
|
var sr = new StreamReader(fileName);
|
||||||
|
var line = string.Empty;
|
||||||
|
|
||||||
|
while ((line = sr.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
list.Add(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
sr.Close();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Excersise3/Excersise3/Program.cs
Normal file
36
Excersise3/Excersise3/Program.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Excersise3
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
ListLoader myLoader = new ListLoader();
|
||||||
|
List<string> languages = new List<string>();
|
||||||
|
|
||||||
|
languages = myLoader.LoadListFromFile("languages.txt");
|
||||||
|
|
||||||
|
Console.Write("List languages containing: ");
|
||||||
|
string searchFor = Console.ReadLine();
|
||||||
|
|
||||||
|
var result = from a in languages
|
||||||
|
where a.ToLower().Contains(searchFor.ToLower())
|
||||||
|
select a;
|
||||||
|
|
||||||
|
foreach (var item in result)
|
||||||
|
{
|
||||||
|
Console.WriteLine(item);
|
||||||
|
}
|
||||||
|
WaitForInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void WaitForInput()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Press Enter...");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Excersise3/Excersise3/Properties/AssemblyInfo.cs
Normal file
36
Excersise3/Excersise3/Properties/AssemblyInfo.cs
Normal file
@@ -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("Excersise3")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Excersise3")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||||
|
[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("fc9c7672-9abd-4040-aa81-2777019590db")]
|
||||||
|
|
||||||
|
// 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")]
|
||||||
22
Excersise4/Excersise4.sln
Normal file
22
Excersise4/Excersise4.sln
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.31101.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Excersise4", "Excersise4\Excersise4.csproj", "{D2DA5FD4-C060-4394-B0B8-0A851DD44B12}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{D2DA5FD4-C060-4394-B0B8-0A851DD44B12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D2DA5FD4-C060-4394-B0B8-0A851DD44B12}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D2DA5FD4-C060-4394-B0B8-0A851DD44B12}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D2DA5FD4-C060-4394-B0B8-0A851DD44B12}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
6
Excersise4/Excersise4/App.config
Normal file
6
Excersise4/Excersise4/App.config
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
60
Excersise4/Excersise4/Excersise4.csproj
Normal file
60
Excersise4/Excersise4/Excersise4.csproj
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{D2DA5FD4-C060-4394-B0B8-0A851DD44B12}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Excersise4</RootNamespace>
|
||||||
|
<AssemblyName>Excersise4</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="LanguageData.cs" />
|
||||||
|
<Compile Include="ListLoader.cs" />
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
15
Excersise4/Excersise4/LanguageData.cs
Normal file
15
Excersise4/Excersise4/LanguageData.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Excersise4
|
||||||
|
{
|
||||||
|
class LanguageData
|
||||||
|
{
|
||||||
|
public string Name;
|
||||||
|
public int Year;
|
||||||
|
public string Description;
|
||||||
|
}
|
||||||
|
}
|
||||||
33
Excersise4/Excersise4/ListLoader.cs
Normal file
33
Excersise4/Excersise4/ListLoader.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Excersise4
|
||||||
|
{
|
||||||
|
class ListLoader
|
||||||
|
{
|
||||||
|
public List<LanguageData> LoadListFromFile(string fileName)
|
||||||
|
{
|
||||||
|
var list = new List<LanguageData>();
|
||||||
|
var sr = new StreamReader(fileName);
|
||||||
|
var line = string.Empty;
|
||||||
|
|
||||||
|
while ((line = sr.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
LanguageData OneLineOfData = new LanguageData();
|
||||||
|
string [] temp = line.Split('\t');
|
||||||
|
OneLineOfData.Name = temp[0];
|
||||||
|
OneLineOfData.Year = int.Parse(temp[1]);
|
||||||
|
OneLineOfData.Description = temp[2];
|
||||||
|
|
||||||
|
list.Add(OneLineOfData);
|
||||||
|
}
|
||||||
|
|
||||||
|
sr.Close();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
40
Excersise4/Excersise4/Program.cs
Normal file
40
Excersise4/Excersise4/Program.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Excersise4
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
ListLoader myLoader = new ListLoader();
|
||||||
|
List<LanguageData> languages = new List<LanguageData>();
|
||||||
|
|
||||||
|
languages = myLoader.LoadListFromFile("languageData.txt");
|
||||||
|
|
||||||
|
Console.Write("Minimum Year: ");
|
||||||
|
string minimumYear = Console.ReadLine();
|
||||||
|
Console.Write("Maximum Year: ");
|
||||||
|
string maximumYTear = Console.ReadLine();
|
||||||
|
|
||||||
|
var result = from a in languages
|
||||||
|
where a.Year > int.Parse(minimumYear) && a.Year < int.Parse(maximumYTear)
|
||||||
|
select a;
|
||||||
|
|
||||||
|
foreach (var item in result)
|
||||||
|
{
|
||||||
|
Console.WriteLine(item.Description);
|
||||||
|
}
|
||||||
|
WaitForInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void WaitForInput()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Press Enter...");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Excersise4/Excersise4/Properties/AssemblyInfo.cs
Normal file
36
Excersise4/Excersise4/Properties/AssemblyInfo.cs
Normal file
@@ -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("Excersise4")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Excersise4")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||||
|
[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("49f80c7b-69de-4a04-81f6-d45d560c8e22")]
|
||||||
|
|
||||||
|
// 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")]
|
||||||
22
Exercise5/Exercise5.sln
Normal file
22
Exercise5/Exercise5.sln
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.31101.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercise5", "Exercise5\Exercise5.csproj", "{C6760286-A4B9-4319-8BF2-980E111498AD}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{C6760286-A4B9-4319-8BF2-980E111498AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C6760286-A4B9-4319-8BF2-980E111498AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C6760286-A4B9-4319-8BF2-980E111498AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C6760286-A4B9-4319-8BF2-980E111498AD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
6
Exercise5/Exercise5/App.config
Normal file
6
Exercise5/Exercise5/App.config
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
60
Exercise5/Exercise5/Exercise5.csproj
Normal file
60
Exercise5/Exercise5/Exercise5.csproj
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{C6760286-A4B9-4319-8BF2-980E111498AD}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Exercise5</RootNamespace>
|
||||||
|
<AssemblyName>Exercise5</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Weight.cs" />
|
||||||
|
<Compile Include="WeightUnit.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
46
Exercise5/Exercise5/Program.cs
Normal file
46
Exercise5/Exercise5/Program.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Exercise5
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
public static void Main()
|
||||||
|
{
|
||||||
|
var weight = new Weight();
|
||||||
|
|
||||||
|
weight.SetWeight(WeightUnit.Kilogram, 2.0);
|
||||||
|
weight.Add(WeightUnit.Pound, 1.0);
|
||||||
|
weight.Add(WeightUnit.Gram, 450.0);
|
||||||
|
weight.Add(WeightUnit.Ounce, 1234.0);
|
||||||
|
|
||||||
|
Console.WriteLine("2 Kilo + 1 Pound + 450 Gram + 1234 Ounce is");
|
||||||
|
Console.WriteLine("================================================\n");
|
||||||
|
|
||||||
|
// This line prints 2.453592
|
||||||
|
Console.WriteLine("In Kilogram\t" + weight.GetWeight(WeightUnit.Kilogram));
|
||||||
|
|
||||||
|
// This line prints 5.40924
|
||||||
|
Console.WriteLine("In Pounds\t" + weight.GetWeight(WeightUnit.Pound));
|
||||||
|
|
||||||
|
// This line prints
|
||||||
|
Console.WriteLine("In Grams\t" + weight.GetWeight(WeightUnit.Gram));
|
||||||
|
|
||||||
|
// This line prints
|
||||||
|
Console.WriteLine("In Ounces\t" + weight.GetWeight(WeightUnit.Ounce));
|
||||||
|
|
||||||
|
WaitForInput();
|
||||||
|
|
||||||
|
// Dictionary<WeightUnit, double> myDictionary;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WaitForInput()
|
||||||
|
{
|
||||||
|
Console.WriteLine("\nPress enter...");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Exercise5/Exercise5/Properties/AssemblyInfo.cs
Normal file
36
Exercise5/Exercise5/Properties/AssemblyInfo.cs
Normal file
@@ -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("Exercise5")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Exercise5")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||||
|
[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("6be72068-8462-46b6-94bb-d88bd795effb")]
|
||||||
|
|
||||||
|
// 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")]
|
||||||
72
Exercise5/Exercise5/Weight.cs
Normal file
72
Exercise5/Exercise5/Weight.cs
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Exercise5
|
||||||
|
{
|
||||||
|
class Weight
|
||||||
|
{
|
||||||
|
private double weight = 0; // Nullable Type
|
||||||
|
|
||||||
|
public void SetWeight(WeightUnit weightUnit, double p)
|
||||||
|
{
|
||||||
|
switch (weightUnit)
|
||||||
|
{
|
||||||
|
case WeightUnit.Kilogram:
|
||||||
|
weight = p;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Pound:
|
||||||
|
weight = p * 0.45359237;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Gram:
|
||||||
|
weight = p / 1000;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Ounce:
|
||||||
|
weight = p * 0.0283495231;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(WeightUnit weightUnit, double p)
|
||||||
|
{
|
||||||
|
switch (weightUnit)
|
||||||
|
{
|
||||||
|
case WeightUnit.Kilogram:
|
||||||
|
weight += p;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Pound:
|
||||||
|
weight += p * 0.45359237;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Gram:
|
||||||
|
weight = p / 1000;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Ounce:
|
||||||
|
weight = p * 0.0283495231;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double GetWeight(WeightUnit weightUnit)
|
||||||
|
{
|
||||||
|
switch (weightUnit)
|
||||||
|
{
|
||||||
|
case WeightUnit.Kilogram:
|
||||||
|
return weight;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Pound:
|
||||||
|
return (weight*2.20462262);
|
||||||
|
break;
|
||||||
|
case WeightUnit.Gram:
|
||||||
|
return (weight * 1000);
|
||||||
|
break;
|
||||||
|
case WeightUnit.Ounce:
|
||||||
|
return (weight * 35.2739619);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new NotImplementedException();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
Exercise5/Exercise5/WeightUnit.cs
Normal file
16
Exercise5/Exercise5/WeightUnit.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Exercise5
|
||||||
|
{
|
||||||
|
|
||||||
|
public enum WeightUnit : long
|
||||||
|
{
|
||||||
|
Kilogram,
|
||||||
|
Gram,
|
||||||
|
Pound,
|
||||||
|
Ounce
|
||||||
|
}
|
||||||
|
}
|
||||||
22
Exercise6/Exercise6.sln
Normal file
22
Exercise6/Exercise6.sln
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.31101.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercise6", "Exercise6\Exercise6.csproj", "{6456ED51-C115-41E1-AF2E-7663967825F4}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{6456ED51-C115-41E1-AF2E-7663967825F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6456ED51-C115-41E1-AF2E-7663967825F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6456ED51-C115-41E1-AF2E-7663967825F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6456ED51-C115-41E1-AF2E-7663967825F4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
6
Exercise6/Exercise6/App.config
Normal file
6
Exercise6/Exercise6/App.config
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
56
Exercise6/Exercise6/CustomStack.cs
Normal file
56
Exercise6/Exercise6/CustomStack.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Exercise6
|
||||||
|
{
|
||||||
|
class CustomStack<T> : IEnumerable<T>
|
||||||
|
{
|
||||||
|
private List<T> items = new List<T>();
|
||||||
|
|
||||||
|
public T Peek()
|
||||||
|
{
|
||||||
|
T item = items[0];
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
public T Pop()
|
||||||
|
{
|
||||||
|
T item = items[0];
|
||||||
|
items.RemoveAt(0);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
public T Push(T item)
|
||||||
|
{
|
||||||
|
items.Insert(0, item);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool isEmpty()
|
||||||
|
{
|
||||||
|
if (items.Count == 0)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(T item)
|
||||||
|
{
|
||||||
|
Push(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator<T> GetEnumerator()
|
||||||
|
{
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
yield return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
59
Exercise6/Exercise6/Exercise6.csproj
Normal file
59
Exercise6/Exercise6/Exercise6.csproj
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{6456ED51-C115-41E1-AF2E-7663967825F4}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Exercise6</RootNamespace>
|
||||||
|
<AssemblyName>Exercise6</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="CustomStack.cs" />
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
58
Exercise6/Exercise6/Program.cs
Normal file
58
Exercise6/Exercise6/Program.cs
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Exercise6
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
var myScienceStack = new CustomStack<string>();
|
||||||
|
|
||||||
|
myScienceStack.Push("Carl Sagan");
|
||||||
|
myScienceStack.Push("Albert Einstein");
|
||||||
|
myScienceStack.Push("Stephen Hawking");
|
||||||
|
myScienceStack.Push("Neil deGrasse Tyson");
|
||||||
|
myScienceStack.Push("Wolfgang Pauli");
|
||||||
|
myScienceStack.Push("Edsger Dijkstra");
|
||||||
|
myScienceStack.Push("Bjarne Stroustrup");
|
||||||
|
myScienceStack.Push("Linus Torvalds");
|
||||||
|
*/
|
||||||
|
|
||||||
|
var myScienceStack = new CustomStack<string> ()
|
||||||
|
{
|
||||||
|
"Carl Sagan",
|
||||||
|
"Albert Einstein",
|
||||||
|
"Stephen Hawking",
|
||||||
|
"Neil deGrasse Tyson",
|
||||||
|
"Wolfgang Pauli",
|
||||||
|
"Edsger Dijkstra",
|
||||||
|
"Bjarne Stroustrup",
|
||||||
|
"Linus Torvalds"
|
||||||
|
};
|
||||||
|
|
||||||
|
show(myScienceStack);
|
||||||
|
WaitForInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void show(CustomStack<string> myScienceStack)
|
||||||
|
{
|
||||||
|
foreach (var person in myScienceStack)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Person: " + person);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void WaitForInput()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Press Enter...");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Exercise6/Exercise6/Properties/AssemblyInfo.cs
Normal file
36
Exercise6/Exercise6/Properties/AssemblyInfo.cs
Normal file
@@ -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("Exercise6")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Exercise6")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||||
|
[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("d59344ce-38f3-482a-81e4-7abcb43eabd0")]
|
||||||
|
|
||||||
|
// 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")]
|
||||||
22
Exercise8/Exercise8.sln
Normal file
22
Exercise8/Exercise8.sln
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.31101.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercise8", "Exercise8\Exercise8.csproj", "{A83951A4-9AC1-4697-8F7E-7EBA3410028B}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{A83951A4-9AC1-4697-8F7E-7EBA3410028B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{A83951A4-9AC1-4697-8F7E-7EBA3410028B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A83951A4-9AC1-4697-8F7E-7EBA3410028B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{A83951A4-9AC1-4697-8F7E-7EBA3410028B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
6
Exercise8/Exercise8/App.config
Normal file
6
Exercise8/Exercise8/App.config
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
61
Exercise8/Exercise8/Exercise8.csproj
Normal file
61
Exercise8/Exercise8/Exercise8.csproj
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{A83951A4-9AC1-4697-8F7E-7EBA3410028B}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Exercise8</RootNamespace>
|
||||||
|
<AssemblyName>Exercise8</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Weight.cs" />
|
||||||
|
<Compile Include="WeightExtensions.cs" />
|
||||||
|
<Compile Include="WeightUnit.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
29
Exercise8/Exercise8/Program.cs
Normal file
29
Exercise8/Exercise8/Program.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Exercise8
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
// Create a new Weight from a double of 2.5 Pounds
|
||||||
|
double w = 2.5;
|
||||||
|
var weightFromDouble = w.ConvertToWeight(WeightUnit.Pound);
|
||||||
|
|
||||||
|
// Create a new Weight from a double of 2.5 Pounds
|
||||||
|
var weightFromString = "15".ConvertToWeight(WeightUnit.Ounce);
|
||||||
|
|
||||||
|
weightFromDouble.PrintMe(WeightUnit.Kilogram);
|
||||||
|
weightFromString.PrintMe(WeightUnit.Pound);
|
||||||
|
|
||||||
|
WaitForInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WaitForInput()
|
||||||
|
{
|
||||||
|
Console.WriteLine("\nPress a key...");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Exercise8/Exercise8/Properties/AssemblyInfo.cs
Normal file
36
Exercise8/Exercise8/Properties/AssemblyInfo.cs
Normal file
@@ -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("Exercise8")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Exercise8")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||||
|
[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("3a112416-4ffe-4cf8-9977-e7102c114dbf")]
|
||||||
|
|
||||||
|
// 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")]
|
||||||
91
Exercise8/Exercise8/Weight.cs
Normal file
91
Exercise8/Exercise8/Weight.cs
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Exercise8
|
||||||
|
{
|
||||||
|
class Weight
|
||||||
|
{
|
||||||
|
private double weight = 0; // Nullable Type
|
||||||
|
|
||||||
|
public void SetWeight(WeightUnit weightUnit, double newWeight)
|
||||||
|
{
|
||||||
|
switch (weightUnit)
|
||||||
|
{
|
||||||
|
case WeightUnit.Kilogram:
|
||||||
|
weight = newWeight;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Pound:
|
||||||
|
weight = newWeight * 0.45359237;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Gram:
|
||||||
|
weight = newWeight / 1000;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Ounce:
|
||||||
|
weight = newWeight * 0.0283495231;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(WeightUnit weightUnit, double p)
|
||||||
|
{
|
||||||
|
switch (weightUnit)
|
||||||
|
{
|
||||||
|
case WeightUnit.Kilogram:
|
||||||
|
weight += p;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Pound:
|
||||||
|
weight += p * 0.45359237;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Gram:
|
||||||
|
weight = p / 1000;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Ounce:
|
||||||
|
weight = p * 0.0283495231;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double GetWeight(WeightUnit weightUnit)
|
||||||
|
{
|
||||||
|
switch (weightUnit)
|
||||||
|
{
|
||||||
|
case WeightUnit.Kilogram:
|
||||||
|
return weight;
|
||||||
|
break;
|
||||||
|
case WeightUnit.Pound:
|
||||||
|
return (weight*2.20462262);
|
||||||
|
break;
|
||||||
|
case WeightUnit.Gram:
|
||||||
|
return (weight * 1000);
|
||||||
|
break;
|
||||||
|
case WeightUnit.Ounce:
|
||||||
|
return (weight * 35.2739619);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new NotImplementedException();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(Weight w)
|
||||||
|
{
|
||||||
|
weight += w.GetWeight(WeightUnit.Kilogram);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetWeight(Weight w)
|
||||||
|
{
|
||||||
|
SetWeight(WeightUnit.Kilogram, w.GetWeight(WeightUnit.Kilogram));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Weight operator +(Weight leftWeight, Weight rightWeight)
|
||||||
|
{
|
||||||
|
Weight sumWeight = new Weight();
|
||||||
|
|
||||||
|
sumWeight.SetWeight(WeightUnit.Kilogram, leftWeight.GetWeight(WeightUnit.Kilogram) + rightWeight.GetWeight(WeightUnit.Kilogram));
|
||||||
|
|
||||||
|
return sumWeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
Exercise8/Exercise8/WeightExtensions.cs
Normal file
34
Exercise8/Exercise8/WeightExtensions.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Exercise8
|
||||||
|
{
|
||||||
|
static class WeightExtensions
|
||||||
|
{
|
||||||
|
public static Weight ConvertToWeight(this double input, WeightUnit unit)
|
||||||
|
{
|
||||||
|
var w = new Weight();
|
||||||
|
|
||||||
|
w.SetWeight(unit, input);
|
||||||
|
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Weight ConvertToWeight(this string input, WeightUnit unit)
|
||||||
|
{
|
||||||
|
var w = new Weight();
|
||||||
|
|
||||||
|
w.SetWeight(unit, Double.Parse(input));
|
||||||
|
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void PrintMe(this Weight input, WeightUnit unit)
|
||||||
|
{
|
||||||
|
Console.WriteLine("This objects weights " + input.GetWeight(WeightUnit.Kilogram) + " " + unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
Exercise8/Exercise8/WeightUnit.cs
Normal file
16
Exercise8/Exercise8/WeightUnit.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Exercise8
|
||||||
|
{
|
||||||
|
|
||||||
|
public enum WeightUnit : long
|
||||||
|
{
|
||||||
|
Kilogram,
|
||||||
|
Gram,
|
||||||
|
Pound,
|
||||||
|
Ounce
|
||||||
|
}
|
||||||
|
}
|
||||||
22
Exercise9A/Exercise9A.sln
Normal file
22
Exercise9A/Exercise9A.sln
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.31101.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercise9A", "Exercise9A\Exercise9A.csproj", "{8EE7D0DE-EA39-4754-8A55-FB8DC09535D5}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{8EE7D0DE-EA39-4754-8A55-FB8DC09535D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{8EE7D0DE-EA39-4754-8A55-FB8DC09535D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{8EE7D0DE-EA39-4754-8A55-FB8DC09535D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{8EE7D0DE-EA39-4754-8A55-FB8DC09535D5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
6
Exercise9A/Exercise9A/App.config
Normal file
6
Exercise9A/Exercise9A/App.config
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
15
Exercise9A/Exercise9A/Calculator.cs
Normal file
15
Exercise9A/Exercise9A/Calculator.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Exercise9A
|
||||||
|
{
|
||||||
|
class Calculator
|
||||||
|
{
|
||||||
|
public CalcDelegate CalcLogic { get; set; }
|
||||||
|
|
||||||
|
public void PrintCalculation(double a, double b)
|
||||||
|
{
|
||||||
|
double result = CalcLogic(a, b);
|
||||||
|
Console.WriteLine("Result: " + result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
59
Exercise9A/Exercise9A/Exercise9A.csproj
Normal file
59
Exercise9A/Exercise9A/Exercise9A.csproj
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{8EE7D0DE-EA39-4754-8A55-FB8DC09535D5}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Exercise9A</RootNamespace>
|
||||||
|
<AssemblyName>Exercise9A</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Calculator.cs" />
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
28
Exercise9A/Exercise9A/Program.cs
Normal file
28
Exercise9A/Exercise9A/Program.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Exercise9A
|
||||||
|
{
|
||||||
|
public delegate double CalcDelegate(double a, double b);
|
||||||
|
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var myCalculator = new Calculator();
|
||||||
|
//myCalculator.CalcLogic = (a, b) => Math.Pow(a, b);
|
||||||
|
//myCalculator.CalcLogic = (a, b) => a + b;
|
||||||
|
myCalculator.CalcLogic = (a, b) => a - b;
|
||||||
|
myCalculator.PrintCalculation(3, 4);
|
||||||
|
|
||||||
|
|
||||||
|
WaitForInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WaitForInput()
|
||||||
|
{
|
||||||
|
Console.WriteLine("\nEnter a key...");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Exercise9A/Exercise9A/Properties/AssemblyInfo.cs
Normal file
36
Exercise9A/Exercise9A/Properties/AssemblyInfo.cs
Normal file
@@ -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("Exercise9A")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Exercise9A")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||||
|
[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("913ba60c-7623-436c-8d7e-fdbbdb8b1163")]
|
||||||
|
|
||||||
|
// 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")]
|
||||||
22
Exercise9B/Exercise9B.sln
Normal file
22
Exercise9B/Exercise9B.sln
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.31101.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercise9B", "Exercise9B\Exercise9B.csproj", "{27DD1E20-317D-4C84-9663-D5991EB1F3A0}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{27DD1E20-317D-4C84-9663-D5991EB1F3A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{27DD1E20-317D-4C84-9663-D5991EB1F3A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{27DD1E20-317D-4C84-9663-D5991EB1F3A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{27DD1E20-317D-4C84-9663-D5991EB1F3A0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
6
Exercise9B/Exercise9B/App.config
Normal file
6
Exercise9B/Exercise9B/App.config
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
58
Exercise9B/Exercise9B/Exercise9B.csproj
Normal file
58
Exercise9B/Exercise9B/Exercise9B.csproj
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{27DD1E20-317D-4C84-9663-D5991EB1F3A0}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Exercise9B</RootNamespace>
|
||||||
|
<AssemblyName>Exercise9B</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
52
Exercise9B/Exercise9B/Program.cs
Normal file
52
Exercise9B/Exercise9B/Program.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Exercise9B
|
||||||
|
{
|
||||||
|
static class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var integerList = new List<int> {6, 2, 7, 4, 3, 9, 8, 5, 1};
|
||||||
|
Console.WriteLine("\nUn-ordered List");
|
||||||
|
PrintList(integerList);
|
||||||
|
|
||||||
|
var orderedList = integerList.OrderMyList();
|
||||||
|
Console.WriteLine("\n\nSorted List");
|
||||||
|
PrintList(orderedList);
|
||||||
|
|
||||||
|
WaitForInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PrintList(List<int> result)
|
||||||
|
{
|
||||||
|
foreach (var num in result)
|
||||||
|
{
|
||||||
|
Console.WriteLine(num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static List<int> OrderMyList(this List<int> input)
|
||||||
|
{
|
||||||
|
var newList = new List<int>();
|
||||||
|
|
||||||
|
while (input.Count > 0)
|
||||||
|
{
|
||||||
|
int min = input.Min();
|
||||||
|
newList.Add(min);
|
||||||
|
input.RemoveAt(input.IndexOf(input.Min()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return newList;
|
||||||
|
}
|
||||||
|
private static void WaitForInput()
|
||||||
|
{
|
||||||
|
Console.WriteLine("\nEnter a key...");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Exercise9B/Exercise9B/Properties/AssemblyInfo.cs
Normal file
36
Exercise9B/Exercise9B/Properties/AssemblyInfo.cs
Normal file
@@ -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("Exercise9B")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Exercise9B")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||||
|
[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("b70a050a-1558-417d-acd5-8c5fd645f258")]
|
||||||
|
|
||||||
|
// 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")]
|
||||||
22
SlideTester/SlideTester.sln
Normal file
22
SlideTester/SlideTester.sln
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.31101.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlideTester", "SlideTester\SlideTester.csproj", "{B1343E62-CD0A-4C9B-B22E-29C8D88AECCE}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{B1343E62-CD0A-4C9B-B22E-29C8D88AECCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B1343E62-CD0A-4C9B-B22E-29C8D88AECCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B1343E62-CD0A-4C9B-B22E-29C8D88AECCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B1343E62-CD0A-4C9B-B22E-29C8D88AECCE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
6
SlideTester/SlideTester/App.config
Normal file
6
SlideTester/SlideTester/App.config
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
39
SlideTester/SlideTester/Program.cs
Normal file
39
SlideTester/SlideTester/Program.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SlideTester
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
enum Days { Sat, Sun, Mon, Tue, Wed, Thu, Fri };
|
||||||
|
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
string Namnet = "Christian";
|
||||||
|
string Name = null;
|
||||||
|
Console.WriteLine(Name ?? "No name set");
|
||||||
|
|
||||||
|
int x = 42;
|
||||||
|
Console.WriteLine(x.Double());
|
||||||
|
|
||||||
|
WaitForInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void WaitForInput()
|
||||||
|
{
|
||||||
|
Console.WriteLine("\nPress a key...");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class Extension
|
||||||
|
{
|
||||||
|
public static int Double(this int input)
|
||||||
|
{
|
||||||
|
return input*2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
SlideTester/SlideTester/Properties/AssemblyInfo.cs
Normal file
36
SlideTester/SlideTester/Properties/AssemblyInfo.cs
Normal file
@@ -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("SlideTester")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("SlideTester")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||||
|
[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("a34a1956-9ec3-4574-8714-c30b3ef94bd1")]
|
||||||
|
|
||||||
|
// 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")]
|
||||||
58
SlideTester/SlideTester/SlideTester.csproj
Normal file
58
SlideTester/SlideTester/SlideTester.csproj
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{B1343E62-CD0A-4C9B-B22E-29C8D88AECCE}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>SlideTester</RootNamespace>
|
||||||
|
<AssemblyName>SlideTester</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
22
Structs/ConsoleSlask.sln
Normal file
22
Structs/ConsoleSlask.sln
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.31101.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleSlask", "ConsoleSlask\ConsoleSlask.csproj", "{AD447D40-3ED5-466E-BE8C-8A6004B7DE7D}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{AD447D40-3ED5-466E-BE8C-8A6004B7DE7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{AD447D40-3ED5-466E-BE8C-8A6004B7DE7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{AD447D40-3ED5-466E-BE8C-8A6004B7DE7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{AD447D40-3ED5-466E-BE8C-8A6004B7DE7D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
6
Structs/ConsoleSlask/App.config
Normal file
6
Structs/ConsoleSlask/App.config
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
58
Structs/ConsoleSlask/ConsoleSlask.csproj
Normal file
58
Structs/ConsoleSlask/ConsoleSlask.csproj
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{AD447D40-3ED5-466E-BE8C-8A6004B7DE7D}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>ConsoleSlask</RootNamespace>
|
||||||
|
<AssemblyName>ConsoleSlask</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
43
Structs/ConsoleSlask/Program.cs
Normal file
43
Structs/ConsoleSlask/Program.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ConsoleSlask
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
public struct Person
|
||||||
|
{
|
||||||
|
public string FirstName { get; set; }
|
||||||
|
public string LastName { get; set; }
|
||||||
|
public int YearOfBirth;
|
||||||
|
|
||||||
|
// En låtsas-konstruktor för en Struct
|
||||||
|
public Person(string firstName, string lastName, int yearOfBirth) : this()
|
||||||
|
{
|
||||||
|
FirstName = firstName;
|
||||||
|
LastName = lastName;
|
||||||
|
YearOfBirth = yearOfBirth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void WaitForInput()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Press Enter...");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PrintPerson(Person p)
|
||||||
|
{
|
||||||
|
Console.WriteLine("FirstName: " + p.FirstName);
|
||||||
|
Console.WriteLine("LastName: " + p.LastName);
|
||||||
|
Console.WriteLine("YearOfBirth: " + p.YearOfBirth);
|
||||||
|
WaitForInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello World!");
|
||||||
|
Person p = new Person(firstName: "Christian", lastName: "Ohlsson", yearOfBirth: 1973);
|
||||||
|
PrintPerson(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Structs/ConsoleSlask/Properties/AssemblyInfo.cs
Normal file
36
Structs/ConsoleSlask/Properties/AssemblyInfo.cs
Normal file
@@ -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("ConsoleSlask")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("ConsoleSlask")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||||
|
[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("75b54cd6-0425-4e5a-a948-95ccdab69382")]
|
||||||
|
|
||||||
|
// 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")]
|
||||||
Reference in New Issue
Block a user