如何分离长文本 [英] How to dissociate a long text

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

问题描述

嗨!
请您能帮我分解ASP.NET中的文本,让该程序像新闻一样写阅读更多..."吗?谢谢.

Hi!
Please can you help me to dissociate a text in ASP.NET to let this program to write "Read more..." just like news...??? Thank you.

推荐答案

以下链接帮助您作为起点.
1. 以长文本插入刹车 [ ^ ]
2.
The following links help you as starting point.
1.Inserting brakes in a long text[^]
2.Split Long Text into meaningful sentences with certain length using C#[^]

Good luck.


我写了这样的课:

使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;


公共字符串insertBreak(字符串strMessage,int cdeIndex)
{
字符串jobname = strMessage;
如果(jobname.Length> cdeIndex)
{
int k = cdeIndex;
int j =(jobname.Length/k);


for(int i = 0; i< j; i ++)
{
int cdeDifference = 0;
int cdeFindspace = 0;
如果((k + 10)< jobname.Length)
{
cdeFindspace = jobname.IndexOf(",k-2,10);
}
否则{cdeFindspace = -1; }
如果(cdeFindspace!= -1)
{
cdeDifference = cdeFindspace-k;
k = cdeFindspace;

}
jobname = jobname.Insert(k,``< br/>''));
如果((k +(k + 6))< jobname.Length)
{
k = k +(k + 6)+(cdeDifference);
}
其他
{
休息;

}
}
}
返回工作名称;
}

但是那是一行错误:

公共字符串insertBreak(字符串strMessage,int cdeIndex)

消息:
类,委托,枚举,....

问题在哪里?以及tu如何使用此类中断文本?谢谢.
I wrote the class like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;


public string insertBreak(string strMessage, int cdeIndex)
{
String jobname = strMessage;
if (jobname.Length > cdeIndex)
{
int k = cdeIndex;
int j = (jobname.Length / k);


for (int i = 0; i < j; i++)
{
int cdeDifference = 0;
int cdeFindspace = 0;
if ((k + 10) < jobname.Length)
{
cdeFindspace = jobname.IndexOf(" ", k - 2, 10);
}
else { cdeFindspace = -1; }
if (cdeFindspace != -1)
{
cdeDifference = cdeFindspace - k;
k = cdeFindspace;

}
jobname = jobname.Insert(k, "<br />");
if ((k + (k + 6)) < jobname.Length)
{
k = k + (k + 6) + (cdeDifference);
}
else
{
break;

}
}
}
return jobname;
}

But ther is an error in line :

public string insertBreak(string strMessage, int cdeIndex)

The message:
class, delegate, enum, ....

Where is th problem? and how tu use this class for breaking the text? Thank you.


这篇关于如何分离长文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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