public function keepformat(content)
  if typename(content)=null or isnull(content) then
   keepformat=""
  else
   content=replace(content," "," ")
   content=replace(content,chr(13)&chr(10),"<br/>")
   keepformat=content
  end if
 end function转换成C#的!

解决方案 »

  1.   

    public string keepformat(string content)
    {
      if (content=String.Empty || content="")
    {
        return "";
    }
      else
    {
       
       content=content.replace(" ","&nbsp;");
       content=content.replace(chr(13)&chr(10),"<br/>");
       return content;
    }
    }在网吧,没办法试!
      

  2.   

    “string”并不包含对“replace”的定义
    好象content=content.replace(" ","&nbsp;");这句不对
      

  3.   

    replace 改成Replace就行了但是还有错误: 名称“chr”在类或命名空间“mytxl.bbs.computer_hardware.newtopic”中不存在
    chr(13)  好象也不对
      

  4.   

    content=content.Replace(" ","&nbsp;");
    content=content.Replace("\n","<br/>");
    content=content.Replace("\r","<br/>");
      

  5.   

    我用上面的函数在数据库里添加了记录,也将空格,回车之类的替换了,我查看了在数据库中的字段内容为:
    in&nbsp;&nbsp;web.config&nbsp;&nbsp;<br/>&nbsp;<br/><httpRuntime&nbsp;&nbsp;executionTimeout="90"&nbsp;&nbsp;maxRequestLength="100000"&nbsp;&nbsp;useFullyQualifiedRedirectUrl="false"&nbsp;&nbsp;/><br/><br/><br/>http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=164613<br/>为什么在取出时就少东西了,我用table显示的!显示结果不是:
    in  web.config  
     
    <httpRuntime  executionTimeout="90"  maxRequestLength="100000"  useFullyQualifiedRedirectUrl="false"  />
    http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=164613
    而是:
    in  web.config  
     
    http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=164613
    这是为什么啊!
      

  6.   

    好象<  和  />符号中间的东西都不显示!怎么解决啊 
      

  7.   

    以下代码由http://www.carlosag.net/Tools/CodeTranslator/Default.aspx自动转换生成
        public void keepformat(void content) {
            if (((typename(content) == null) 
                        || isnull(content))) {
                keepformat = "";
            }
            else {
                content = content.Replace(" ", " ");
                content = content.Replace(('\r' + '\n'), "<br/>");
                keepformat = content;
            }
        }
      

  8.   

    http://www.developerfusion.com/utilities/convertvbtocsharp.aspxvb转换到C#,译得很准啊.