我试过这个:
richTextBoxResults.Text = listStrSessionIdLines.ToString();
Run Code Online (Sandbox Code Playgroud)
...但是获取List的ToString()表示(我猜它就是这样:"System.Collections.Generic.List`1 [System.String]").
......我试过试试这个:
listStrSessionIdLines.CopyTo(richTextBoxResults.Lines);
Run Code Online (Sandbox Code Playgroud)
...但是我得到了," Argument Exception未处理.目标数组不够长.检查destIndex和length,以及数组的下限. "
这是否意味着我必须首先为RichTextBox分配一些行,或者...... ???
我想根据传递给表单构造函数的项(在本例中为List <int>)填充CheckedListBox .
我的骨架代码是:
foreach (int platypus in listPlatypi)
{
userFriendlyPlatypusName = ExpandFromPlatypusID(platypus);
// I want to store a verbose string in an Item of the CheckedListBox, something like:
// Item item = new Item(userFriendlyPlatypusName); // what data type should "Item" be?
CheckedListBox1.Add(item);
}
Run Code Online (Sandbox Code Playgroud) 我想自动化Outlook,以便我可以下载电子邮件的"部分",以便我可以将相关的邮件绑定在一起.我知道电子邮件通常有一个"MessageID"来实现此目的,因此可以在上下文中查看电子邮件,因为新闻阅读器中的"线程"是捆绑在一起的.
Outlook是否在与其一起发送的电子邮件中具有"邮件ID"的概念?我看到可以提取的元素(使用自动化)是Subject,SenderEmail,CreationTime,Body,SenderName和HTMLBody.在某个地方也可以使用"消息ID"或等效内容吗?
使用此代码:
for (int row = 0; row < PlatypusGridRowCount; row++) {
// Save each row as an array
var currentRowContents = new string[ColumnCount];
// Add each column to the currentColumn
for (int col = 0; col < ColumnCount; col++) {
currentRowContents[col] = this.GetPlatypusValForCell(row, col);
}
// Add the row to the DGV
dataGridViewPlatypus.Rows.Add(currentRowContents);
Run Code Online (Sandbox Code Playgroud)
Resharper谈到最后一行:"从字符串[]到对象[]的共变量数组转换会导致写入操作的运行时异常"
所以我让它进行它想要的更改("将局部变量的类型更改为object [] ..."),以便代码变为:
...
object[] currentRowContents = new string[ColumnCount];
...
Run Code Online (Sandbox Code Playgroud)
然后,当我重新运行Resharper检查时,我再次从Resharper获得完全相同的确切警告消息("从字符串[]到对象[]的共变量数组转换可能导致写入操作的运行时异常"),但这次在线上:
object[] currentRowContents = new string[ColumnCount];
Run Code Online (Sandbox Code Playgroud)
然后我让它再做一次("将局部变量的类型改为string [] ...")
...所以这会将该行更改为:
string[] currentRowContents = new string[PLATYPUS_COL_COUNT];
Run Code Online (Sandbox Code Playgroud)
...(IOW,它将其更改回第一个版本,但使用显式而非隐式字符串数组声明); …
遗留代码以这种方式执行:
public bool isValidField(string tableName, string fieldName)
{
bool retVal;
string tblQuery = string.Format("SELECT {0} FROM {1}", fieldName, tableName);
checkConnection();
try
{
SqlCeCommand cmd = objCon.CreateCommand();
cmd.CommandText = tblQuery;
object objvalid = cmd.ExecuteScalar();
retVal = (null != objvalid);
}
catch
{
retVal = false;
}
return retVal;
}
Run Code Online (Sandbox Code Playgroud)
...但我发现它并不总是有效.调用该方法后,获取false,一些代码ALTERS表添加一些列,但我得到:
列ID在规范中出现多次.
我在StackOverflow上找到了几个有前途的SQL语句:
if exists(select * from sys.columns
where Name = N'columnName' and Object_ID = Object_ID(N'tableName'))
Run Code Online (Sandbox Code Playgroud)
和
IF COL_LENGTH('table_name','column_name') IS NULL
Run Code Online (Sandbox Code Playgroud)
...但我不确定如何在C#/ .NET 1.1中实现它
我是否需要使用ExecuteScalar并将返回的值转换为bool?或者是其他东西?
改变它并没有纠正问题:
public bool isValidField(string …Run Code Online (Sandbox Code Playgroud) 在编译从VS2003中的.NET 1.1移植到VS2008中的.NET 3.5的解决方案时,我得到了一些建议,其中一个是有代表性的:
考虑app.config重新映射程序集"System.Windows.Forms,Culture = neutral,PublicKeyToken = 969db8053d3322ac,Retargetable = Yes"从版本"1.0.5000.0"[]到版本"2.0.0.0"[C:\ Program Files(x86) )\ Microsoft.NET\SDK\CompactFramework\v2.0\WindowsCE\System.Windows.Forms.dll]解决冲突并摆脱警告.
解决方案中的任何项目都没有app.config文件.但是,有很多*.resx文件包含"Version = 1.0.5000.0"
我应该进行全局搜索并替换那些"Version = 2.0.0.0"或者我应该如何纠正这个问题?
我选择了"项目>升级项目",重建,现在消息包括:
C:\ Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets:警告MSB3245:无法解析此引用.找不到程序集"System.Windows.Forms.DataGrid".检查以确保磁盘上存在程序集.如果您的代码需要此引用,则可能会出现编译错误.
无法解决"System.Xml,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 969db8053d3322ac,Retargetable = Yes"和"System.Xml,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089"之间的冲突.选择"System.Xml,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 969db8053d3322ac,Retargetable = Yes".
无法解决"System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 969db8053d3322ac,Retargetable = Yes"和"System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089"之间的冲突.选择"System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 969db8053d3322ac,Retargetable = Yes"任意选择.
考虑将版本"System.Windows.Forms,Culture = neutral,PublicKeyToken = 969db8053d3322ac,Retargetable = Yes"的app.config重新映射从版本"1.0.5000.0"[]到版本"3.5.0.0"[C:\ Program Files(x86) )\ …
我用这个代码在这里尝试调用REST控制器方法从一个Compact Framework的客户端的Web API的服务器应用程序:
public static void SendXMLFile3(string uri, string data)
{
WebRequest request = WebRequest.Create (uri);
request.Method = "POST";
string postData = data;
byte[] byteArray = Encoding.UTF8.GetBytes (postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream ();
dataStream.Write (byteArray, 0, byteArray.Length);
dataStream.Close ();
WebResponse response = request.GetResponse ();
MessageBox.Show(((HttpWebResponse) response).StatusDescription);
dataStream = response.GetResponseStream ();
StreamReader reader = new StreamReader (dataStream);
string responseFromServer = reader.ReadToEnd();
MessageBox.Show(responseFromServer);
reader.Close ();
dataStream.Close ();
response.Close ();
}
Run Code Online (Sandbox Code Playgroud)
...我早些时候曾尝试过这段代码,这是我从“Microsoft .NET Compact Framework”一书中得到的: …
我有一个Web API应用程序,它使用一个控制器返回从文件读取的数据.
所以我所使用的只是MVC的C(控制器)部分.我没有视图,我也没有使用模型 - 我正在存储和检索App_Data文件夹中的数据.
我知道这是一个相当简单的解决方案,但似乎我只需要C而不是MVC.我错过了什么吗?
我的SSRS报告中需要一个行值,该值是基于报告中已经使用的几个字段计算出来的.我希望它显示在名为'textboxPercentageValue'的文本框中.在半简单英语中,表达式/公式为:
If the value of the "Week" field is "WK1", display the value of the Variance field divided by the value of the Price field; otherwise, just display the value from the Variance field.
Run Code Online (Sandbox Code Playgroud)
在VB脚本gobbledygook中,我添加到textboxPercentageValue的Value属性的表达式/公式是:
=IIF((Fields!Week.Value="WK1"), Fields!Variance.Value / Fields!Price.Value, Fields!Variance.Value)
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试将.rdl文件上传到SQL Server Reporting Services时,我得到:
" 文本框'textboxPercentageValue'的值表达式直接指向字段'Week'而不指定数据集聚合.当报表包含多个数据集时,数据区域外的字段引用必须包含在指定数据集范围的聚合函数中.(rsFieldReferenceAmbiguous)获取联机帮助文本框'textboxPercentageValue'的值表达式直接指向字段'Variance'而不指定数据集聚合.当报表包含多个数据集时,数据区域外的字段引用必须包含在聚合函数中指定数据集范围.(rsFieldReferenceAmbiguous)获取联机帮助文本框'textboxPercentageValue'的值表达式直接指向字段'Price'而不指定数据集聚合.当报表包含多个数据集时,数据区域外的字段引用必须包含在指定数据集范围的聚合函数中.(rs FieldReferenceAmbiguous)获取联机帮助文本框'textboxPercentageValue'的值表达式直接指向字段'Variance'而不指定数据集聚合.当报表包含多个数据集时,数据区域外的字段引用必须包含在指定数据集范围的聚合函数中.(rsFieldReferenceAmbiguous) "
那么我需要做些什么来使这个表达式/公式明确无法与SQL Server Reporting Services或VBScript解析器或"谁"抱怨它?
我在C#中创建一个HTML表,如下所示:
int quadCheck = -1;
int rowNum = 0;
foreach (ProduceUsage puRec in puList)
{
builder.Append("<tr align='left' valign='top'>");
quadCheck++;
rowNum++;
// Print the Description on the first iteration of every four rows
if ((quadCheck.Equals(0)) || (quadCheck % 4 == 0))
{
rowNum = 1;
builder.Append("<td rowspan=\"4\" class=\"description\">");
builder.Append(puRec.ItemDescription.ToUpper());
builder.Append("</td>");
}
if (rowNum.Equals(PACKAGES))
{
builder.Append("<td>");
builder.Append(DATA_ROWLET1_TOTAL_PACKAGES);
builder.Append("</td>");
builder.Append("<td>");
builder.Append(puRec.PackagesMonth1);
builder.Append("</td>");
builder.Append("<td>");
builder.Append(puRec.PackagesMonth2);
builder.Append("</td>");
builder.Append("<td>");
builder.Append(puRec.PackagesMonth3);
builder.Append("</td>");
builder.Append("<td>");
builder.Append(puRec.PackagesMonth4);
builder.Append("</td>");
builder.Append("<td>");
builder.Append(puRec.PackagesMonth5);
builder.Append("</td>");
builder.Append("<td>");
builder.Append(puRec.PackagesMonth6);
builder.Append("</td>");
builder.Append("<td>");
builder.Append(puRec.PackagesMonth7);
builder.Append("</td>");
builder.Append("<td>");
builder.Append(puRec.PackagesMonth8);
builder.Append("</td>"); …Run Code Online (Sandbox Code Playgroud) c# ×8
winforms ×3
aggregates ×1
app-config ×1
arraylist ×1
arrays ×1
asp.net-mvc ×1
assemblies ×1
automation ×1
bids ×1
dynamic ×1
generics ×1
html ×1
html-table ×1
outlook ×1
rdl ×1
resharper ×1
resx ×1
richtextbox ×1
sql ×1
stream ×1
vbscript ×1
versioning ×1
webrequest ×1
webresponse ×1
windows-ce ×1