我正在为一个班级做一个项目.我要做的是将解析的指令导出到文件.Microsoft有这个例子,它解释了如何写入文件:
// Compose a string that consists of three lines.
string lines = "First line.\r\nSecond line.\r\nThird line.";
// Write the string to a file.
System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt");
file.WriteLine(lines);
file.Close();
Run Code Online (Sandbox Code Playgroud)
我对那部分很好,但有没有办法将文件写入当前项目的环境/位置?我想这样做,而不是硬编码特定的路径(即"C:\\test.txt").
我正在做一些学习,我遇到了一个问题,要求显示以下代码的正确内存图:
int [] d1 = new int[5];
d1[0] = 3;
Integer [] d2 = new Integer[5];
d2[0] = new Integer(3);
ArrayList d3 = new ArrayList();
d3.add(3);
Run Code Online (Sandbox Code Playgroud)
这是我对内存图的尝试,但可能不正确:

我理解对象,实例变量和"新"实例都在堆上,局部变量和基本类型之类的东西都在堆栈上,但在数组类型方面我仍然感到困惑.
任何帮助表示赞赏.