15. 結果はどうなる?(その4)
interface IValue<T> { T Value { get; set; } }
struct ValueStruct<T> : IValue<T>
{
public T Value { get; set; }
public override string ToString()
=> $"Value is {Value?.ToString() ?? "null"}!";
}
{
:
void changeValue<T>(ValueStruct<T> target, T value) => target.Value = value;
var v = new ValueStruct<int>() { Value = 5 };
changeValue(v, 100);
WriteLine(v);
}
18. 結果はどうなる?(その5)
interface IValue<T> { T Value { get; set; } }
struct ValueStruct<T> : IValue<T>
{
public T Value { get; set; }
public override string ToString()
=> $"Value is {Value?.ToString() ?? "null"}!";
}
{
:
void changeValue<T>(IValue<T> target, T value) => target.Value = value;
var v = new ValueStruct<int>() { Value = 5 };
changeValue(v, 100);
WriteLine(v);
}