Kar*_*ran 6 .net c# reflection
我试图使用反射拉出项目名称,但在substring方法中它给我"索引超出范围的错误".
string s = System.Reflection.Assembly.GetExecutingAssembly().Location;
int idx = s.LastIndexOf(@"\");
s = s.Substring(idx, s.Length);
Run Code Online (Sandbox Code Playgroud)
我不明白为什么它会在第三行给出错误.
Plz帮助.
Mic*_*len 14
尝试:
System.IO.Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9546 次 |
| 最近记录: |