String machineName = System.Environment.MachineName;
String filePath = @"E:\folder1\folder2\file1";
int a = filePath.IndexOf(System.IO.Path.DirectorySeparatorChar);
filePath = filePath.Substring(filePath.IndexOf(System.IO.Path.DirectorySeparatorChar) +1);
String networdPath = System.IO.Path.Combine(string.Concat(System.IO.Path.DirectorySeparatorChar, System.IO.Path.DirectorySeparatorChar), machineName, filePath);
Console.WriteLine(networdPath);
Run Code Online (Sandbox Code Playgroud)
我使用String.Concat和编写了上述代码Path.Combine以获取网络路径。但这只是一种解决方法,而不是具体的解决方案,可能会失败。是否有获取网络路径的具体解决方案?
const name = 1;
name = 2;
Run Code Online (Sandbox Code Playgroud)
执行此JavaScript时出现错误:
TypeError: Assignment to constant variable.
at Object.<anonymous> (/home/user01/JavaScript/scope.js:2:6)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
Run Code Online (Sandbox Code Playgroud)
但是,在执行以下语句时,代码会成功执行.
const arr = [1,2,3];
arr[1] = 5;
Run Code Online (Sandbox Code Playgroud)
为什么我们能够修改数组,即使它被声明为常量.