在pdfsharp上显示System.String []而不是value? [英] System.String[] will be displayed instead of value on pdfsharp?

查看:76
本文介绍了在pdfsharp上显示System.String []而不是value?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用pdfsharp来创建pdf。我有一个很大的文本值,所以它不适合我的表格列。所以我尝试过分裂功能。但pdf上打印的值是System.String []。这是我的代码:



I am using pdfsharp to create pdf. I have got a big text value, so that its not fit into my table column. So that I have tried split function. But the value printed on pdf is System.String[]. Here is my code:

private string[] GetLines(string strValue)
{
    string[] strLines = strValue.Split('\n');
    int lineLength = strLines.Length;
    return strLines;
}

DataRow repRow = ReportDS.Rows[rowCount];
string Result = repRow["result"].ToString();
//result.length is 558
if (Result.Length > 50)
{
    Result = GetLines(Result).ToString();
}





值得到的结果是System.String []。我需要获取值。



The value get on Result is System.String[]. I need to get values.

推荐答案

1。你怎么画它?

2.你可能要求它一次绘制整个对象,比如pdf.Draw(Result.ToString())。

那个给你类型的名称。

逐行绘制。
1. How do you draw it?
2. You probably asked it to draw the entire object at once, something like pdf.Draw(Result.ToString()).
That gives you the name of the type.
Draw it line by line.


这确实是正确的。您正在为结果设置一个数组,因为您将结果设置为 GetLines(Result)这是一个数组。
That is indeed correct. You are setting an array to the result since you are setting Result to GetLines(Result) which is an array.


你期待看到什么? GetLines是一个数组,它没有作为字符串的自然表示,因此当您使用ToString时,它返回类型名称,这就是您看到string []的原因。将其视为字符串的最简单方法是使用string.Join



What are you expecting to see? GetLines is an array, it has no natural representation as a string so when you use ToString it returns the type name which is why you see "string[]". The easiest way to see it as a string is to use string.Join

Result = string.Join (", ", GetLines(Result))





上面会显示每个元素以逗号分隔



e1 ,e2等





the above will show each element comma separated

e1, e2, etc

Result = string.Join (" ", GetLines(Result))





将在一行中显示



e1 e2等



或许你想用html中断显示它们,如果这就是你的PDF工作方式





will show then in a line

e1 e2 etc

Or maybe you want to show them with html breaks if that is how your PDF works

Result = string.Join ("<br />", GetLines(Result))





我们不知道你希望阵列看起来像什么很难给出明确的答案。



We don't know what you want the array to look like so it's hard to give a definitive answer.


这篇关于在pdfsharp上显示System.String []而不是value?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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