字符串问题 [英] string question

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

问题描述

我在C#中有一个简单的字符串问题:


a这样的VB.NET语句:

sb.Append(Chr(34)& ; myReader.GetValue(i).ToString& Chr(34)& vbCrLf)


那么,对于Chr(34)和vbCrLf,我需要在C#中使用什么?


谢谢大家。

J.

Hi, I have a simple string question in C#:

a VB.NET statement like this:
sb.Append(Chr(34) & myReader.GetValue(i).ToString & Chr(34) & vbCrLf)

So, for Chr(34) and vbCrLf, what I need to use in C#?

Thanks all.
J.

推荐答案



我假设sb是一个StringBuilder实例:

sb.Append((char)34);

sb.Append(myReader。 GetValue(i));

sb.Append((char)34);

sb.Append(" \ n");


干杯,

-

Ignacio Machin,

ignacio.machin at dot.state.fl.us

佛罗里达州交通局

J < j@NoSpam.org>在消息中写道

新闻:ao ******************************** @ 4ax.com ...
Hi,

I assume that sb is a StringBuilder instance:
sb.Append( (char)34 );
sb.Append( myReader.GetValue(i) );
sb.Append( (char)34 );
sb.Append( "\n" );

Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"J" <j@NoSpam.org> wrote in message
news:ao********************************@4ax.com...
我在C#中有一个简单的字符串问题:

这样的VB.NET语句:
sb.Append(Chr(34) & myReader.GetValue(i).ToString& Chr(34)& vbCrLf)

那么,对于Chr(34)和vbCrLf,我需要在C#中使用什么?

谢谢大家。
J。
Hi, I have a simple string question in C#:

a VB.NET statement like this:
sb.Append(Chr(34) & myReader.GetValue(i).ToString & Chr(34) & vbCrLf)

So, for Chr(34) and vbCrLf, what I need to use in C#?

Thanks all.
J.



你好J,


只是为了添加对于Ignacio的回复,你可能想要使用\\ n而不仅仅是\ n,因为\ n只是没有返回的换行符(通常是enought,但可能并不总是)。


或者你可以使用与系统无关的Environment.NewLine,它会在当前系统上产生\\\\ n或等效物。


-

快乐的编码!

Morten Wennevik [C#MVP]
Hi J,

Just to add to Ignacio''s reply, you might want to use \r\n instead of just \n as \n is just the newline character without the return (usually enought, but maybe not always).

Alternately you can use Environment.NewLine which is system independent and will produce \r\n or the equivalent on your current system.

--
Happy coding!
Morten Wennevik [C# MVP]


另外,请注意Chr(34)是与''\''''相同(那是单引号,

反斜杠,双引号,单引号)


你也可以这样写:


sb.AppendFormat(" \" {0} \" \\\\ n",myReader.GetValue(i));

-

真相,

James Curran

主页: www.noveltheory.com 工作: www.njtheater.com

博客: www.honestillusion.com 日工作: www.partsearch.com

(注意新的一天工作!)

" J" < j@NoSpam.org>在消息中写道

新闻:ao ******************************** @ 4ax.com ...
Also, note the Chr(34) is the same as ''\"'' (that''s single-quote,
back-slash, double-quote, single-quote)

You could also write that as:

sb.AppendFormat("\"{0}\"\r\n", myReader.GetValue(i));

--
Truth,
James Curran
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
(note new day job!)
"J" <j@NoSpam.org> wrote in message
news:ao********************************@4ax.com...
我在C#中有一个简单的字符串问题:

这样的VB.NET语句:
sb.Append(Chr(34) & myReader.GetValue(i).ToString& Chr(34)& vbCrLf)

那么,对于Chr(34)和vbCrLf,我需要在C#中使用什么?

全部谢谢。
J。
Hi, I have a simple string question in C#:

a VB.NET statement like this:
sb.Append(Chr(34) & myReader.GetValue(i).ToString & Chr(34) & vbCrLf)

So, for Chr(34) and vbCrLf, what I need to use in C#?

Thanks all.
J.



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

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