Skip to content

Instantly share code, notes, and snippets.

@toya33
Created December 2, 2014 15:02
Show Gist options
  • Save toya33/625557d2a47b36ed7a17 to your computer and use it in GitHub Desktop.
Save toya33/625557d2a47b36ed7a17 to your computer and use it in GitHub Desktop.
Structの間違った使い方
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