如何删除文本文件中不需要的空格 [英] how to remove unwanted spaces in text file

查看:80
本文介绍了如何删除文本文件中不需要的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

我从后端获取250个承包商的记录,并使用字符串生成器将其存储在每个单独的字符串生成器中,然后将数据从这些列表中追加到数组列表中,从而生成文件格式.

在这里,我遇到了一些问题,即单词(或)单词的末尾(或单词的开头)之间显示了多余的空间,此问题发生在文件的第13条记录以及db中没有空格.


好的,任何人都可以帮助我.

Hi!

From back end I''m fetching 250 records of contractors and storing in each separate string builder using string builder I''m append the data to the array list from these generating the file format.

Here I''m struggling with some problem that is unwanted space is displaying in between the word (or) end of the word (or) starting of the word, this issue is occurring in the every 13th record of the file and in db there is no spaces.


Kindly any one can help me.

推荐答案

使用Replace方法.
use Replace method.
String.Replace(" ","");


在这里删除字符串中的空格


Here am removing spaces in a string


您是否尝试过使用 Trim [ ^ ],它消除了前导和尾随空格.

参阅更多:
C#中的修剪字符串 [ http://msdn.microsoft.com/en-us/library/t97s7bs3.aspx [ ^ ]
Have you tried with Trim[^], which eliminates leading and trailing whitespace.

Refer More:
Trim String in C#[^]

Have a look on detailed description on MSDN:
http://msdn.microsoft.com/en-us/library/t97s7bs3.aspx[^]


strText.tostring().replace(" ","");


这篇关于如何删除文本文件中不需要的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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