为什么字符串显示长度值? [英] why string showing length value?

查看:68
本文介绍了为什么字符串显示长度值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DirectoryInfo dir = new DirectoryInfo(@"D:\Temp");
FileInfo[] y = dir.GetFiles();
List<string> asx = y.Select(p => new { File = p.DirectoryName + p.Name }.ToString()).ToList();
datagridview1.datasource=asx;









为什么列表asx显示长度:33,11,20 ...... ?????





代码块添加 - OriginalGriff

固定标记拼写错误 - Matt Heffron [/ edit]





why list asx showing length: 33,11,20...?????


[edit]Code block added - OriginalGriff
Fixed markup typo - Matt Heffron[/edit]

推荐答案

对我来说,它不是:

For me, it doesn''t:
DirectoryInfo dir = new DirectoryInfo(@"D:\Temp");
FileInfo[] y = dir.GetFiles();
List<string> asx = y.Select(p => new { File = p.DirectoryName + p.Name }.ToString()).ToList();

它返回一个字符串数组:

It returns an array of strings:

foreach (string s in asx)
    {
    Console.WriteLine(s);
    }

打印:

Prints:

{ File = D:\TempAA.TXT }
{ File = D:\TempAAdel.jpg }
{ File = D:\TempMyIP.aspx }
{ File = D:\TempMyPic.jpg }
{ File = D:\TempMyText.txt }
{ File = D:\TempTestingSQLite.sldb }
{ File = D:\TempThumbs.db }}

那我在做什么你不是,反之亦然?



顺便说一句:您可能想在目录和文件名之间添加\\。

So what am I doing that you aren''t, or vice versa?

BTW: You probably want to add a "\\" in there, between the directory and file names.


这篇关于为什么字符串显示长度值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆