本文整理汇总了C#中System.Text.StringBuilder类的典型用法代码示例。如果您正苦于以下问题:C# System.Text.StringBuilder类的具体用法?C# System.Text.StringBuilder怎么用?C# System.Text.StringBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Text.StringBuilder类属于命名空间,在下文中一共展示了System.Text.StringBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Collect
public override void Collect(int doc, float score)
{
try
{
int op = order[(opidx[0]++) % order.Length];
//System.out.println(op==skip_op ? "skip("+(sdoc[0]+1)+")":"next()");
bool more = op == skip_op?scorer.SkipTo(sdoc[0] + 1):scorer.Next();
sdoc[0] = scorer.Doc();
float scorerScore = scorer.Score();
float scorerScore2 = scorer.Score();
float scoreDiff = System.Math.Abs(score - scorerScore);
float scorerDiff = System.Math.Abs(scorerScore2 - scorerScore);
if (!more || doc != sdoc[0] || scoreDiff > maxDiff || scorerDiff > maxDiff)
{
System.Text.StringBuilder sbord = new System.Text.StringBuilder();
for (int i = 0; i < order.Length; i++)
sbord.Append(order[i] == skip_op?" skip()":" next()");
throw new System.SystemException("ERROR matching docs:" + "\n\t" + (doc != sdoc[0]?"--> ":"") + "doc=" + sdoc[0] + "\n\t" + (!more?"--> ":"") + "tscorer.more=" + more + "\n\t" + (scoreDiff > maxDiff?"--> ":"") + "scorerScore=" + scorerScore + " scoreDiff=" + scoreDiff + " maxDiff=" + maxDiff + "\n\t" + (scorerDiff > maxDiff?"--> ":"") + "scorerScore2=" + scorerScore2 + " scorerDiff=" + scorerDiff + "\n\thitCollector.doc=" + doc + " score=" + score + "\n\t Scorer=" + scorer + "\n\t Query=" + q + " " + q.GetType().FullName + "\n\t Searcher=" + s + "\n\t Order=" + sbord + "\n\t Op=" + (op == skip_op?" skip()":" next()"));
}
}
catch (System.IO.IOException e)
{
throw new System.Exception("", e);
}
}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:25,代码来源:QueryUtils.cs
示例2: ToString
public override string ToString()
{
var sb = new System.Text.StringBuilder();
sb.AppendLine(string.Format("{0}: {1}", "X", X));
sb.AppendLine(string.Format("{0}: {1}", "Y", Y));
return sb.ToString();
}
开发者ID:RaptorFactor,项目名称:devmaximus,代码行数:7,代码来源:Vector2.cs
示例3: getMD516
public string getMD516(string str)
{
//类型转换
byte[] myByte = System.Text.Encoding.ASCII.GetBytes(str);
sbyte[] mySByte = new sbyte[myByte.Length];
for (int i = 0; i < myByte.Length; i++)
{
if (myByte[i] > 127)
mySByte[i] = (sbyte)(myByte[i] - 256);
else
mySByte[i] = (sbyte)myByte[i];
}
md5Init();
md5Update(mySByte, str.Length);
md5Final();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
for (int i = 0; i < 8; i++)
{
sb.Append(byteHEX(digest[i]));
}
return sb.ToString();
}
开发者ID:caocf,项目名称:workspace-kepler,代码行数:26,代码来源:Md5.cs
示例4: ToString
/// <summary>
/// Converts a number to System.String.
/// </summary>
/// <param name="number"></param>
/// <returns></returns>
public static System.String ToString(long number)
{
System.Text.StringBuilder s = new System.Text.StringBuilder();
if (number == 0)
{
s.Append("0");
}
else
{
if (number < 0)
{
s.Append("-");
number = -number;
}
while (number > 0)
{
char c = digits[(int)number % 36];
s.Insert(0, c);
number = number / 36;
}
}
return s.ToString();
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:31,代码来源:Number.cs
示例5: Encode
public static System.String Encode(System.String s)
{
int length = s.Length;
System.Text.StringBuilder buffer = new System.Text.StringBuilder(length * 2);
for (int i = 0; i < length; i++)
{
char c = s[i];
int j = (int) c;
if (j < 0x100 && encoder[j] != null)
{
buffer.Append(encoder[j]); // have a named encoding
buffer.Append(';');
}
else if (j < 0x80)
{
buffer.Append(c); // use ASCII value
}
else
{
buffer.Append("&#"); // use numeric encoding
buffer.Append((int) c);
buffer.Append(';');
}
}
return buffer.ToString();
}
开发者ID:emtees,项目名称:old-code,代码行数:26,代码来源:Entities.cs
示例6: HandlerAddSimulationRequest
protected string HandlerAddSimulationRequest()
{
System.Text.StringBuilder sbResult = new System.Text.StringBuilder();
try
{
string strId = string.Empty;
int Id = default(int);
if (CY.Utility.Common.RequestUtility.IsGet)
{
strId = CY.Utility.Common.RequestUtility.GetQueryString("Id");
}
else if (CY.Utility.Common.RequestUtility.IsPost)
{
strId = CY.Utility.Common.RequestUtility.GetFormString("Id");
}
if (string.IsNullOrEmpty(strId) || !CY.Utility.Common.ParseUtility.TryParseInt32(strId, out Id))
{
return sbResult.Append("{success:false,action:'none',status:'none',msg:'参数错误!'}").ToString();
}
CY.CSTS.Core.Business.StimulationType type = new CY.CSTS.Core.Business.StimulationType();
}
catch (Exception ex)
{
throw ex;
}
finally
{
}
return string.Empty;
}
开发者ID:dalinhuang,项目名称:cy-csts,代码行数:35,代码来源:AddStimulationType.ashx.cs
示例7: Next
/// <summary>Returns the next token in the stream, or null at EOS.
/// <p>Removes <tt>'s</tt> from the end of words.
/// <p>Removes dots from acronyms.
/// </summary>
public override Monodoc.Lucene.Net.Analysis.Token Next()
{
Monodoc.Lucene.Net.Analysis.Token t = input.Next();
if (t == null)
return null;
System.String text = t.TermText();
System.String type = t.Type();
if ((System.Object) type == (System.Object) APOSTROPHE_TYPE && (text.EndsWith("'s") || text.EndsWith("'S")))
{
return new Monodoc.Lucene.Net.Analysis.Token(text.Substring(0, (text.Length - 2) - (0)), t.StartOffset(), t.EndOffset(), type);
}
else if ((System.Object) type == (System.Object) ACRONYM_TYPE)
{
// remove dots
System.Text.StringBuilder trimmed = new System.Text.StringBuilder();
for (int i = 0; i < text.Length; i++)
{
char c = text[i];
if (c != '.')
trimmed.Append(c);
}
return new Monodoc.Lucene.Net.Analysis.Token(trimmed.ToString(), t.StartOffset(), t.EndOffset(), type);
}
else
{
return t;
}
}
开发者ID:emtees,项目名称:old-code,代码行数:35,代码来源:StandardFilter.cs
示例8: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
try
{
Session["MainUrl"].ToString();
}
catch (NullReferenceException)
{
Response.Redirect("~/");
return;
}
Debug.WriteLine(">>>> CodeQuality");
this.sitemap = (List<string>)Session["selectedSites"];
var ths = new ThreadStart(TestCodeQuality);
var th = new Thread(ths);
th.Start();
th.Join();
var sb = new System.Text.StringBuilder();
CodeQualitySession.RenderControl(new System.Web.UI.HtmlTextWriter(new System.IO.StringWriter(sb)));
string htmlstring = sb.ToString();
Session["CodeQuality"] = htmlstring;
}
开发者ID:Peacefield,项目名称:DotsolutionsWebsiteTester,代码行数:27,代码来源:CodeQuality.aspx.cs
示例9: DetermineRecipientCount
protected string DetermineRecipientCount()
{
string strCounties = (AllCounties.Checked) ? "All" : Session["Criteria-County"].ToString();
string strSchools = (AllSchools.Checked) ? "All" : Session["Criteria-School"].ToString();
string strGrades = (AllGrades.Checked) ? "All" : Session["Criteria-Grade"].ToString();
string strCareers = (AllCareers.Checked) ? "All" : Session["Criteria-Career"].ToString();
string strClusters = (AllClusters.Checked) ? "All" : Session["Criteria-Cluster"].ToString();
string strGender = Session["GenderChoice"].ToString();
System.Text.StringBuilder sbSQL = new System.Text.StringBuilder();
sbSQL.Append("select count(portfolioid) from PortfolioUserInfo where active=1 and ConSysID=" + ConSysID);
if (strGender != "All")
sbSQL.Append(" and GenderID in (" + strGender + ")");
if (strGrades != "All")
sbSQL.Append(" and GradeNumber in (" + strGrades + ")");
if (strSchools != "All")
sbSQL.Append(" and SchoolID in (" + strSchools + ")");
if (strCounties != "All")
sbSQL.Append(" and CountyID in (" + strCounties + ")");
if (strCareers != "All")
sbSQL.Append(" and PortfolioID in (Select PortfolioID from Port_SavedCareers where OccNumber in (" + strCareers + "))");
if (strClusters != "All")
sbSQL.Append(" and PortfolioID in (Select PortfolioID from Port_ClusterInterests where ClusterID in (" + strClusters + "))");
return CCLib.Common.DataAccess.GetValue(sbSQL.ToString()).ToString();
}
开发者ID:nehawadhwa,项目名称:ccweb,代码行数:27,代码来源:TopMessageNew.aspx.cs
示例10: AddEscapes
/// <summary> Replaces unprintable characters by their espaced (or unicode escaped)
/// equivalents in the given string
/// </summary>
protected internal static System.String AddEscapes(System.String str)
{
System.Text.StringBuilder retval = new System.Text.StringBuilder();
char ch;
for (int i = 0; i < str.Length; i++)
{
switch (str[i])
{
case (char) (0):
continue;
case '\b':
retval.Append("\\b");
continue;
case '\t':
retval.Append("\\t");
continue;
case '\n':
retval.Append("\\n");
continue;
case '\f':
retval.Append("\\f");
continue;
case '\r':
retval.Append("\\r");
continue;
case '\"':
retval.Append("\\\"");
continue;
case '\'':
retval.Append("\\\'");
continue;
case '\\':
retval.Append("\\\\");
continue;
default:
if ((ch = str[i]) < 0x20 || ch > 0x7e)
{
System.String s = "0000" + System.Convert.ToString(ch, 16);
retval.Append("\\u" + s.Substring(s.Length - 4, (s.Length) - (s.Length - 4)));
}
else
{
retval.Append(ch);
}
continue;
}
}
return retval.ToString();
}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:63,代码来源:TokenMgrError.cs
示例11: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
try
{
string title = "Error Sesión Expirada", message = "Su sesión ha expirado.", actualPage = Request.QueryString["aspxerrorpath"];
string currentPage = this.Session["CurrentPage"] as string;
System.Text.StringBuilder errorMessage = new System.Text.StringBuilder();
errorMessage.AppendFormat("{0}. La sesión de usuario expiró. URL: (aspxerrorpath) = {1} - (session) = {2}.", title, actualPage, currentPage);
log.Warn(errorMessage.ToString());
Session.RemoveAll();
Session.Abandon();
Ext.Net.X.Msg.Show(new Ext.Net.MessageBoxConfig
{
Closable = false,
Title = title,
Message = message,
Buttons = Ext.Net.MessageBox.Button.OK,
Handler = "window.parent.location = 'Default.aspx'"
});
}
catch (Exception ex)
{
log.Fatal("Error fatal al cargar pagina de sesion expirada.", ex);
}
}
开发者ID:xapiz,项目名称:COCASJOL,代码行数:29,代码来源:ExpiredSession.aspx.cs
示例12: SendForgotLoginEmail
private void SendForgotLoginEmail(DataTable dtUserInfo, string PortTypeID)
{
System.Text.StringBuilder sbMessage = new System.Text.StringBuilder();
string strEmailSubject = CCLib.Common.Strings.GenerateLanguageText(5386, "English", false, PortTypeID);
if (dtUserInfo.Rows.Count > 1)
{
sbMessage.AppendLine("We have found more than one " + CCLib.Common.Strings.GenerateLanguageText(5386, "English", false, PortTypeID) + " account in our database with your email address.");
sbMessage.AppendLine();
sbMessage.Append("The access information for each of these accounts appears below:");
}
else
{
sbMessage.AppendLine("To login to your " + CCLib.Common.Strings.GenerateLanguageText(5386, "English", false, PortTypeID) + " account, please use the following:");
}
sbMessage.AppendLine();
sbMessage.AppendLine("http://www.careercruising.com/" + CCLib.Common.Strings.GenerateLanguageText(8917, "English", false, PortTypeID));
sbMessage.AppendLine();
for (int c = 0; c < dtUserInfo.Rows.Count; c++)
{
sbMessage.AppendLine("Institution Name: " + dtUserInfo.Rows[c]["InstitutionName"].ToString());
sbMessage.AppendLine("Username: " + dtUserInfo.Rows[c]["Username"].ToString());
sbMessage.AppendLine("Password: " + dtUserInfo.Rows[c]["Password"].ToString());
sbMessage.AppendLine("Advisor Password: " + dtUserInfo.Rows[c]["AdminPassword"].ToString());
sbMessage.AppendLine();
}
sbMessage.AppendLine("Sincerely,");
sbMessage.AppendLine("The Career Cruising Support Team");
CCLib.Common.Email.SendEmail("[email protected]", dtUserInfo.Rows[0]["Email"].ToString(), strEmailSubject, sbMessage.ToString());
}
开发者ID:nehawadhwa,项目名称:ccweb,代码行数:32,代码来源:ForgotLogin.aspx.cs
示例13: Main
public static void Main(string[] args)
{
System.IO.StreamReader reader = OpenInput(args);
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
if (line == null)
continue;
int[] romanValues = new int[] { 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000 };
string[] romanStrings = new string[] { "I", "IV", "V", "IX", "X", "XL", "L", "XC", "C", "CD", "D", "CM", "M" };
int num = System.Int32.Parse(line.Trim());
System.Text.StringBuilder output = new System.Text.StringBuilder();
while(num > 0)
{
for(int i = romanValues.Length - 1; i >= 0; --i)
{
if (romanValues[i] <= num)
{
num -= romanValues[i];
output.Append(romanStrings[i]);
break;
}
}
}
System.Console.WriteLine(output.ToString());
}
}
开发者ID:tamirh,项目名称:CodeEvalPractice,代码行数:31,代码来源:RomanNumerals.cs
示例14: ddlDestino_SelectedIndexChanged
protected void ddlDestino_SelectedIndexChanged(object sender, EventArgs e)
{
SqlDataAdapter da;
DataSet ds;
try
{
System.Data.SqlClient.SqlConnection conn;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
//Set the DataAdapter's query.
da = new SqlDataAdapter("Select '0' as 'Id', 'DESTINO' as 'Descripcion' union select IdDestino as 'Id', UPPER(Descripcion) as 'Descripcion' from Destinos order by 'Id'", conn);
ds = new DataSet();
da.Fill(ds);
ddlDestino.DataSource = ds;
ddlDestino.DataValueField = "Id";
ddlDestino.DataTextField = "Descripcion";
ddlDestino.DataBind();
ds.Dispose();
conn.Close();
}
catch (Exception ex)
{
}
}
开发者ID:nalia2015,项目名称:tusegurodeviaje1,代码行数:31,代码来源:index.aspx.cs
示例15: ProcessRequest
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";//
string ClassId = context.Request.QueryString["ClassId"].ToString();//班级Id
ClassInfo classInfo = ClassInfo.Load(Convert.ToInt32(ClassId));
if (classInfo != null)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("{success: true, classInfo: [");
sb.Append("{ ID:'" + classInfo.Id + "'} ,");
sb.Append("{ Name:'" + classInfo.Name + "'} ,");
sb.Append("{ PersonsNum:'" + classInfo.PersonsNum + "'} ,");
sb.Append("{ MajorId:'" + classInfo.MajorId + "'} ,");
sb.Append("{ DateCreated:'" + classInfo.DateCreated + "'} ,");
sb.Append("{ GradeId:'" + classInfo.GradeId + "'} ,");
sb.Append("{ GradeYear:'" + classInfo.GradeYear + "'}");
sb.Append("]}");
context.Response.Write(sb.ToString());//返回数组
}
else
{
context.Response.Write("{success:false,msg:'班级不存在,或已删除。'}");
}
}
开发者ID:dalinhuang,项目名称:ume-v3,代码行数:28,代码来源:ClassInfoEdit.ashx.cs
示例16: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if ( LRegistro.ExisteSesion( Session ) )
{
if ( !IsPostBack )
{
// Si utilizamos using System.Text no hace falta invocar con System.Text.StringBuilder()
System.Text.StringBuilder sbMiSaludo = new System.Text.StringBuilder();
sbMiSaludo.AppendFormat("Hola {0}", LRegistro.NombreUsuario(Session));
liSaludo.Text = sbMiSaludo.ToString();
System.Text.StringBuilder sbMiSaludo2 = new System.Text.StringBuilder();
sbMiSaludo2.Append("Hola ");
sbMiSaludo2.Append(LRegistro.NombreUsuario(Session));
// sbMiSaludo2.Append("Hola " + LRegistro.NombreUsuario(Session));
} // IsPosBack
}
else
{
// Si no hay sessión le expulso
Response.Redirect("index.aspx");
}
}
开发者ID:jotacero,项目名称:ligotea,代码行数:27,代码来源:_Conectada.Master.cs
示例17: btnSave_Click
protected void btnSave_Click(object sender, EventArgs e)
{
contact.addContact(
Guid.Parse(hfUserId.Value),
txtAddAddress.Text,
txtAddHomeAddress.Text,
txtAddCity.Text,
txtAddProvince.Text,
txtAddZipCode.Text,
txtAddCountry.Text,
txtAddPhoneNumber.Text,
txtAddEmail.Text,
txtAddGuardianName.Text,
txtAddRelationship.Text,
txtAddGuardianAddress.Text,
txtAddGuardianPhone.Text);
BindData();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(@"<script type='text/javascript'>");
sb.Append("$('#addModal').modal('hide');");
sb.Append(@"</script>");
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "HideShowModalScript", sb.ToString(), false);
}
开发者ID:ismaeljaycarpio,项目名称:vs2013,代码行数:25,代码来源:Contacts.aspx.cs
示例18: GetHidimHeader
private static string GetHidimHeader(string filename, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("hidim is torrents!");
sb.AppendFormat("i{0}e", height);
sb.AppendFormat("{0}:{1}", Path.GetFileName(filename).Length, Path.GetFileName(filename));
try
{
using (FileStream fs = File.OpenRead(filename))
{
byte[] hash = new System.Security.Cryptography.SHA1Managed().ComputeHash(fs);
string sha1 = BitConverter.ToString(hash).Replace("-", "");
sb.AppendFormat("{0}:{1}", sha1.Length, sha1);
}
}
catch (Exception)
{
sb.AppendFormat("{0}:{1}", 40, "deadbeefdeadbeefdeadbeefdeadbeebadcoffee");
}
sb.AppendFormat("i{0}e", new FileInfo(filename).Length);
return sb.ToString();
}
开发者ID:Chrisso,项目名称:Tools,代码行数:26,代码来源:Converter.cs
示例19: MainMenu
public MainMenu(XmlDocument pagedata, List<ModuleParams> moduleparams, XmlNamespaceManager pagenamespaces)
: base(pagedata, moduleparams, pagenamespaces)
{
menulist = new System.Text.StringBuilder();
sm = new SessionManagement();
ActiveNetworkRelationshipTypes.ClassURI = "";
}
开发者ID:shariqatariq,项目名称:profiles-rns,代码行数:7,代码来源:MainMenu.ascx.cs
示例20: CreateXmlOpenTag
/// <summary>
/// Creates the XML open tag string for an XElement.
/// </summary>
/// <param name="element">The element.</param>
/// <returns>The XML open tag. In case of an element without value, the tag is self-closing.</returns>
internal static string CreateXmlOpenTag(System.Xml.Linq.XElement element)
{
var builder = new System.Text.StringBuilder();
builder.Append("<");
var name = element.Name.LocalName;
builder.Append(Settings.Default.Formatting_CommentXmlTagsToLowerCase ? name.ToLowerInvariant() : name);
if (element.HasAttributes)
{
foreach (var attr in element.Attributes())
{
builder.Append(Spacer);
builder.Append(attr);
}
}
if (element.IsEmpty)
{
if (Settings.Default.Formatting_CommentXmlSpaceSingleTags)
{
builder.Append(Spacer);
}
builder.Append("/");
}
builder.Append(">");
var result = builder.ToString();
return Settings.Default.Formatting_CommentXmlKeepTagsTogether ? SpaceToFake(result) : result;
}
开发者ID:adontz,项目名称:codemaid,代码行数:37,代码来源:CodeCommentHelper.cs
注:本文中的System.Text.StringBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论