Created
November 28, 2017 15:29
-
-
Save Lycheejam/5914036c85162aa1594cccf8086d3acc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace kisoren | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
//参照型 | |
MyClass a = new MyClass { X = 100, Y = 200 }; | |
//値型 | |
MyStruct b = new MyStruct { X = 200, Y = 100 }; | |
Console.WriteLine("Init"); | |
Console.WriteLine(" MyClass:mc X={0} Y={1}", a.X, a.Y); | |
Console.WriteLine(" MyStruct:ms X={0} Y={1}", b.X, b.Y); | |
Print(a, b); | |
Console.WriteLine("Main"); | |
Console.WriteLine(" MyClass:mc X={0} Y={1}",a.X, a.Y); | |
Console.WriteLine(" MyStruct:ms X={0} Y={1}", b.X, b.Y); | |
} | |
public static void Print(MyClass mc, MyStruct ms) | |
{ | |
Console.WriteLine("Print"); | |
mc.X = mc.X * 2; //適当に値を変える | |
mc.Y = mc.Y / 2; | |
Console.WriteLine(" MyClass:mc X={0} Y={1}", mc.X, mc.Y); | |
ms.X = ms.X * 5; //適当に値を変える | |
ms.X = ms.Y / 5; | |
Console.WriteLine(" MyStruct:ms X={0} Y={1}", ms.X, ms.Y); | |
} | |
} | |
class MyClass | |
{ | |
public int X { get; set; } | |
public int Y { get; set; } | |
} | |
struct MyStruct | |
{ | |
public int X { get; set; } | |
public int Y { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment