如何在字符串生成器中使用'%'符号(VB .NET) [英] How to use '%' symbols in string builder (VB .NET)

查看:68
本文介绍了如何在字符串生成器中使用'%'符号(VB .NET)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

strBd.Append(<%ShowFiles()%>)它对我不起作用



我尝试了什么:



我累了(')和(&)但没有工作

解决方案

它确实正是我所期望的:

  Dim  strBd  As   StringBuilder 
strBd.Append( 开始:
strBd.Append( <%ShowFiles() %>
strBd.Append( :End
Console.WriteLine(strBd.ToString())



给我:

开始: <%ShowFiles()%> :结束

这是一个字符串:当你追加otehr字符串时,它将它们添加到字符串中。

如果那不是你想要它做的,你需要要么重新考虑你要做的事情,要么更准确地解释你期望它做什么。


如果你试图附加一个<$ c的返回值$ c>功能然后执行以下操作;



 sb.Append( <%& ShowFiles()。ToString()&  %>
'
sb.AppendFormat( <%{0}%>,{ShowFiles()。ToString()})' 其中0是参数数组的索引


strBd.Append("<%ShowFiles()%>") it's not working for me

What I have tried:

I tired (') and (&) but not working

解决方案

It does exactly what I expected:

Dim strBd As New StringBuilder
strBd.Append("Start: ")
strBd.Append("<%ShowFiles()%>")
strBd.Append(" :End")
Console.WriteLine(strBd.ToString())


Gives me:

Start: <%ShowFiles()%> :End

It's a string: when you append otehr strings, it adds them into the string so far.
If that isn't what you wanted it to do, you need to either rethink what you are trying to do, or explain in much better detail exactly what you do expect it to do.


If you are trying to append the return value of a Function then do the following;

sb.Append("<%" & ShowFiles().ToString() & "%>")
'or
sb.AppendFormat("<%{0}%>", {ShowFiles().ToString()}) 'where 0 is the index of the parameter array


这篇关于如何在字符串生成器中使用'%'符号(VB .NET)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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