I m trying to point the value of a property to an array element, which will be set at a later time. I have the following code:
using System;
public class HelloWorld
{
private static string[] s = new string[] { null };
public static void Main(string[] args)
{
var a = new A();
a.Value = s[0];
Console.WriteLine ("value bef = " + a.Value);
s[0] = "test";
Console.WriteLine ("value aft = " + a.Value);
}
public class A
{
public string Value { get; set; }
}
}
在我管理上述法典时,我取得了以下成果:
value bef =
value aft =
然而,自此 C#用斜体设计,参考文献,预计产出将是
value bef =
value aft = test
Why does this not work? Is there anyway I can do this in C#? Converting A.Value
to a class or s
to an array of A
s is not really an option.