Created
December 2, 2014 15:02
-
-
Save toya33/625557d2a47b36ed7a17 to your computer and use it in GitHub Desktop.
Structの間違った使い方
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 ConsoleApplication7 | |
{ | |
public struct Test | |
{ | |
public int i1; | |
public int i2; | |
public int i3; | |
public string s1; | |
public string s2; | |
public string s3; | |
} | |
public class IntoTest | |
{ | |
Test test; | |
public void intoTest(Test test) | |
{ | |
this.test = test; | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine(DateTime.Now); | |
int count = 100000000; | |
Test test = new Test(); | |
IntoTest intotest = new IntoTest(); | |
for (int i = 0; i < count; i++) | |
{ | |
//structを使用した場合、メモリ上でコピーが発生する | |
intotest.intoTest(test); | |
} | |
Console.WriteLine(DateTime.Now); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment