小编dan*_*aki的帖子

FileHelpers:如何在读取文件时处理引用的字段

这是我想要阅读的数据:

"Adam C. Emality","1Z620Y1V034826","14.40"
"Ethel Baeron","1Z620Y1V034604","15.19"
"Donna Lidt","1Z620Y1V034650","12.37"
Run Code Online (Sandbox Code Playgroud)

然后在读完数据之后,我想在两个集合上执行一个Join,一个是数组,一个是列表 - 我的代码如下.但是在执行读取文件行之后,我的字符串就像这样存储"\"Adam C. Emality\"" "\"1Z620Y1V034826\"" "\"14.40\""......等等.为什么会发生这种情况?我不想包括",我不知道它为什么要加入\.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FileHelpers;
using Parser;

namespace Amazon_File
{
    class SpreadSheet
    {
        public void create(IEnumerable<SpreadList> list)
        {


            var steamengine = new FileHelperEngine<Records>();
            var records = steamengine.ReadFile(@"C:\Users\Danny\Documents\Visual Studio 2013\Projects\Amazon File\Amazon File\Daniel.csv");

            var spreadlist = from x in list
                             join y in records on x.Name equals y.Name
                             select new { y.Name, y.Track, y.worldPrice, …
Run Code Online (Sandbox Code Playgroud)

c# linq filehelpers readfile

2
推荐指数
1
解决办法
2529
查看次数

C#:string.Trim()不删除空格

我有一个提示要求用户输入日期(以特定格式).然后我修剪了字符串,但是如果在我在提示框中点击"Enter"时有一个额外的空格,那么字符串在剪裁后仍然会有一个额外的空格.我也会发布我的提示框代码.我的字符串是:2015年7月29日下午1:32:01 PDT和2015年7月30日下午12:34:27 PDT

    string afterpromptvalue = Prompt.ShowDialog("Enter earliest Date and Time", "Unshipped Orders");
                    afterpromptvalue.Trim();
                    string beforepromptvalue = Prompt.ShowDialog("Enter latest Date and Time", "Unshipped Orders");
                    beforepromptvalue.Trim();

 string format = "MMM dd, yyyy h:mm:ss tt PDT";

            CultureInfo provider = CultureInfo.InvariantCulture;

            afterpromptvalue.Trim();
            beforepromptvalue.Trim();


            DateTime createdAfter = DateTime.ParseExact(afterpromptvalue, format, provider);



            DateTime createdBefore = DateTime.ParseExact(beforepromptvalue, format, provider);

public static class Prompt
{
    public static string ShowDialog(string text, string caption)
    {
        Form prompt = new Form();
        prompt.Width = 500;
        prompt.Height = 150;
        prompt.FormBorderStyle = FormBorderStyle.FixedDialog;
        prompt.Text …
Run Code Online (Sandbox Code Playgroud)

c# datetime parsing trim

0
推荐指数
1
解决办法
619
查看次数

在C#中将集合插入SQL Server表

尝试将一个集合插入到SQL Server 2014中的表中.这是我执行的代码而没有错误但是当我检查我的表时 - 没有添加任何内容.我的集合对象orders不是空的,我可以看到它在调试时有3个成员.

 IEnumerable<CompleteOrderDetails> orders;
 JoinDetails(doc, ns, xmlFragment1, out orders);

 string connectionstring = null;
 SqlConnection conn;
 connectionstring = "Data Source = DANNY; Initial Catalog = Alliance; Integrated Security = SSPI";

 using (conn = new SqlConnection(connectionstring))
 {
    string customerInsert = "INSERT INTO AmazonCustomer (AddressLine1, AddressLine2, AddressLine3, City, StateOrRegion, AmazonOrderId, PostalCode, Title, ItemPrice, ShippingPrice, Quantity) " + 
                            "VALUES (@AddressLine1, @AddressLine2, @AddressLine3, @City, @StateOrRegion, @AmazonOrderId, @PostalCode, @Title, @ItemPrice, @ShippingPrice, @Quantity)";

    using (SqlCommand query = new SqlCommand(customerInsert))
    {
        query.Connection = …
Run Code Online (Sandbox Code Playgroud)

c# sql-server sqlconnection sql-insert

0
推荐指数
1
解决办法
1216
查看次数