別のクラスのメソッドを使用して定数値の値を初期化することは可能ですか?
namespace ConsoleApplication1
{
class Program
{
const int gravit = haha.habc();//something like this
static void Main(string[] args)
{
some codes.....
}
public class haha
{
int gar = 1;
public int habc()
{
int sa = 1;
return sa;
}
}
}
}
たとえば、上記のコードのように (FYI with this code I am gets Expression being assigned to ... must be constant)、そうでない場合は、これと同様のことを行う他の方法があります。