From d55c7aa4846dbadad099dfdbdb6ddb32fcc8013a Mon Sep 17 00:00:00 2001 From: Alex Thomassen Date: Thu, 6 Dec 2018 13:11:18 +0100 Subject: [PATCH] First commit --- .gitattributes | 63 +++++++ .gitignore | 261 ++++++++++++++++++++++++++ ClassDemo1.sln | 25 +++ ClassDemo1/App.config | 6 + ClassDemo1/ClassDemo1.csproj | 53 ++++++ ClassDemo1/Person.cs | 33 ++++ ClassDemo1/Program.cs | 81 ++++++++ ClassDemo1/Properties/AssemblyInfo.cs | 36 ++++ 8 files changed, 558 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 ClassDemo1.sln create mode 100644 ClassDemo1/App.config create mode 100644 ClassDemo1/ClassDemo1.csproj create mode 100644 ClassDemo1/Person.cs create mode 100644 ClassDemo1/Program.cs create mode 100644 ClassDemo1/Properties/AssemblyInfo.cs diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c4efe2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,261 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc \ No newline at end of file diff --git a/ClassDemo1.sln b/ClassDemo1.sln new file mode 100644 index 0000000..34df6d0 --- /dev/null +++ b/ClassDemo1.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassDemo1", "ClassDemo1\ClassDemo1.csproj", "{D52D0E31-7F8C-494A-8261-C4A2AAFE7413}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D52D0E31-7F8C-494A-8261-C4A2AAFE7413}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D52D0E31-7F8C-494A-8261-C4A2AAFE7413}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D52D0E31-7F8C-494A-8261-C4A2AAFE7413}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D52D0E31-7F8C-494A-8261-C4A2AAFE7413}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C9E16090-FD52-4505-9A30-9DD413EC6E1E} + EndGlobalSection +EndGlobal diff --git a/ClassDemo1/App.config b/ClassDemo1/App.config new file mode 100644 index 0000000..7eb8d24 --- /dev/null +++ b/ClassDemo1/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/ClassDemo1/ClassDemo1.csproj b/ClassDemo1/ClassDemo1.csproj new file mode 100644 index 0000000..1e40998 --- /dev/null +++ b/ClassDemo1/ClassDemo1.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {D52D0E31-7F8C-494A-8261-C4A2AAFE7413} + Exe + ClassDemo1 + ClassDemo1 + v4.6.1 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ClassDemo1/Person.cs b/ClassDemo1/Person.cs new file mode 100644 index 0000000..ed03ecc --- /dev/null +++ b/ClassDemo1/Person.cs @@ -0,0 +1,33 @@ +namespace ClassDemo1 +{ + class Person + { + public double Height; + public double Weight; + public string HairColor; + + public Person(double height, double weight, string hairColor) + { + Height = height; + Weight = weight; + HairColor = hairColor; + } + + public string Description(string name) + { + var start = $"{name} er {MeterHoyde()}m høy, veier {Weight} kg og har {HairColor} hÃ¥rfarge."; + + if (MeterHoyde() / Weight < 0.7) + { + start += $"\nMed andre ord; {name} er stuttjukk."; + } + + return start; + } + + public double MeterHoyde() + { + return Height / 100; + } + } +} diff --git a/ClassDemo1/Program.cs b/ClassDemo1/Program.cs new file mode 100644 index 0000000..dc10920 --- /dev/null +++ b/ClassDemo1/Program.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ClassDemo1 +{ + class Program + { + static void Main(string[] args) + { + //var morDi = new Person(154, 300, "svart"); + //Console.WriteLine(morDi.Description("Mordi")); + + var tall = new[] {6, 345, 123, 61, 26, 3453, 3451, 2, 31, 327, 879, 8, 9, 789, 6, 7, 567}; + SkrivUtVersjonEn(tall); + SkrivUtVersjonTo(tall); + SkrivUtVersjonTre(tall); + + Console.ReadLine(); + } + + /// + /// Versjon 1 + /// - Bruker en vanlig for-loop. + /// + /// + static void SkrivUtVersjonEn(int[] liste) + { + Write("Versjon 1:"); + for (int i = 0; i < liste.Length; i++) + { + Write(liste[i]); + } + + // Sett inn tom linje på slutten. + Write("\n"); + } + + /// + /// Versjon 2 + /// - Bruker en foreach-loop. + /// - Trenger da ikke å bruke et tall som "index". + /// + /// + static void SkrivUtVersjonTo(int[] liste) + { + Write("Versjon 2:"); + + foreach (var tallet in liste) + { + Write(tallet); + } + + Write("\n"); + } + + /// + /// Versjon 3: + /// - Ingen loops, bare en string.Join(). + /// - string.Join() lar deg spesifisere en "separator", som f.eks. komma eller bindestrek som vil settes inn mellom hvert tall. + /// + /// + static void SkrivUtVersjonTre(int[] liste) + { + Write("Versjon 3:"); + Write($"Her er tallene: {string.Join(", ", liste)}"); + Write("\n"); + } + + /// + /// Hjelpemetode for Console.WriteLine(). + /// + /// + static void Write(object data) + { + Console.WriteLine(data); + } + } +} diff --git a/ClassDemo1/Properties/AssemblyInfo.cs b/ClassDemo1/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..677e977 --- /dev/null +++ b/ClassDemo1/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ClassDemo1")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ClassDemo1")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[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("d52d0e31-7f8c-494a-8261-c4a2aafe7413")] + +// 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")]