将多个字符串连接成一个字符串 [英] concatenate multiple strings into a single string

查看:136
本文介绍了将多个字符串连接成一个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将两个字符串连接成一个字符串。例如: - 文本文件的路径,例如我的第一个字符串为〜/ Upload /,文件名为abc.txt。我想要将它们组合为〜/ Upload / abc.txt。我该怎么做?帮助我..



提前谢谢..

I want to concatenate two strings into a single string.for ex:- a path to a text file like i have a my first string as "~/Upload/" and a filename as "abc.txt".I want to combine them as "~/Upload/abc.txt".How can i do this?Help Me..

Thanks in advance..

推荐答案

string path = "~/Upload/";
string filename = "abc.txt";
string result = path + filename;


参考



http://msdn.microsoft.com/en-us/ library / ms228504.aspx [ ^ ]


Path.Combine [ ^ ]是另一种与路径连接的简单方法。
Path.Combine[^] is another nice and easy way of doing a concatenation with path.


这篇关于将多个字符串连接成一个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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